Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickfiledialogimpl_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKFILEDIALOGIMPL_P_H
5#define QQUICKFILEDIALOGIMPL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qquicklistview_p.h>
19#include <QtQuickTemplates2/private/qquickdialog_p.h>
20
22
24
25class QQuickComboBox;
27class QQuickTextField;
28class QQuickLabel;
29
35
36class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImpl : public QQuickDialog
37{
39 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
40 Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
41 Q_PROPERTY(QStringList nameFilters READ nameFilters NOTIFY nameFiltersChanged FINAL)
42 Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
43 Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY selectedFileChanged FINAL)
44 Q_PROPERTY(QString currentFolderName READ currentFolderName NOTIFY selectedFileChanged FINAL)
45 QML_NAMED_ELEMENT(FileDialogImpl)
48 Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>)
49 Q_MOC_INCLUDE(<QtQuickDialogs2QuickImpl/private/qquickfolderbreadcrumbbar_p.h>)
50
51public:
52 explicit QQuickFileDialogImpl(QObject *parent = nullptr);
53
54 static QQuickFileDialogImplAttached *qmlAttachedProperties(QObject *object);
55
56 enum class SetReason {
57 // Either user interaction or e.g. a change in ListView's currentIndex after changing its model.
58 External,
59 // As a result of the user setting an initial selectedFile.
60 Internal
61 };
62
63 QUrl currentFolder() const;
64 void setCurrentFolder(const QUrl &currentFolder, SetReason setReason = SetReason::External);
65
66 QUrl selectedFile() const;
67 void setSelectedFile(const QUrl &file);
68 void setInitialCurrentFolderAndSelectedFile(const QUrl &file);
69
70 QSharedPointer<QFileDialogOptions> options() const;
71 void setOptions(const QSharedPointer<QFileDialogOptions> &options);
72
73 QStringList nameFilters() const;
74 void resetNameFilters();
75
76 QQuickFileNameFilter *selectedNameFilter() const;
77
78 void setAcceptLabel(const QString &label);
79 void setRejectLabel(const QString &label);
80
81 QString fileName() const;
82 void setFileName(const QString &fileName);
83
84 QString currentFolderName() const;
85
86public Q_SLOTS:
87 void selectNameFilter(const QString &filter);
88
90 void currentFolderChanged(const QUrl &folderUrl);
91 void selectedFileChanged(const QUrl &selectedFileUrl);
93 void fileSelected(const QUrl &fileUrl);
95
96private:
97 void componentComplete() override;
98 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
99
100 Q_DISABLE_COPY(QQuickFileDialogImpl)
101 Q_DECLARE_PRIVATE(QQuickFileDialogImpl)
102};
103
104class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImplAttached : public QObject
105{
107 Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox WRITE setButtonBox NOTIFY buttonBoxChanged FINAL)
108 Q_PROPERTY(QQuickComboBox *nameFiltersComboBox READ nameFiltersComboBox WRITE setNameFiltersComboBox NOTIFY nameFiltersComboBoxChanged)
109 Q_PROPERTY(QQuickListView *fileDialogListView READ fileDialogListView WRITE setFileDialogListView NOTIFY fileDialogListViewChanged)
110 Q_PROPERTY(QQuickFolderBreadcrumbBar *breadcrumbBar READ breadcrumbBar WRITE setBreadcrumbBar NOTIFY breadcrumbBarChanged)
111 Q_PROPERTY(QQuickLabel *fileNameLabel READ fileNameLabel WRITE setFileNameLabel NOTIFY fileNameLabelChanged FINAL)
112 Q_PROPERTY(QQuickTextField *fileNameTextField READ fileNameTextField WRITE setFileNameTextField NOTIFY fileNameTextFieldChanged FINAL)
113 Q_PROPERTY(QQuickDialog *overwriteConfirmationDialog READ overwriteConfirmationDialog WRITE setOverwriteConfirmationDialog NOTIFY overwriteConfirmationDialogChanged FINAL)
114 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>)
115 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickcombobox_p.h>)
116 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicktextfield_p.h>)
117 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicklabel_p.h>)
118
119public:
121
122 QQuickDialogButtonBox *buttonBox() const;
123 void setButtonBox(QQuickDialogButtonBox *buttonBox);
124
125 QQuickComboBox *nameFiltersComboBox() const;
126 void setNameFiltersComboBox(QQuickComboBox *nameFiltersComboBox);
127
128 QString selectedNameFilter() const;
129 void selectNameFilter(const QString &filter);
130
131 QQuickListView *fileDialogListView() const;
132 void setFileDialogListView(QQuickListView *fileDialogListView);
133
134 QQuickFolderBreadcrumbBar *breadcrumbBar() const;
135 void setBreadcrumbBar(QQuickFolderBreadcrumbBar *breadcrumbBar);
136
137 QQuickLabel *fileNameLabel() const;
138 void setFileNameLabel(QQuickLabel *fileNameLabel);
139
140 QQuickTextField *fileNameTextField() const;
141 void setFileNameTextField(QQuickTextField *fileNameTextField);
142
143 QQuickDialog *overwriteConfirmationDialog() const;
144 void setOverwriteConfirmationDialog(QQuickDialog *dialog);
145
147 void buttonBoxChanged();
148 void nameFiltersComboBoxChanged();
149 void fileDialogListViewChanged();
150 void breadcrumbBarChanged();
151 void fileNameLabelChanged();
152 void fileNameTextFieldChanged();
153 void overwriteConfirmationDialogChanged();
154
155private:
156 Q_DISABLE_COPY(QQuickFileDialogImplAttached)
157 Q_DECLARE_PRIVATE(QQuickFileDialogImplAttached)
158};
159
161
162#endif // QQUICKFILEDIALOGIMPL_P_H
\inmodule QtCore
Definition qobject.h:103
void filterSelected(const QString &filter)
void fileSelected(const QUrl &fileUrl)
void selectedFileChanged(const QUrl &selectedFileUrl)
void currentFolderChanged(const QUrl &folderUrl)
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLsizei const GLchar * label
[43]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLfloat GLfloat GLfloat GLfloat h
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ATTACHED(ATTACHED_TYPE)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_MOC_INCLUDE(...)
#define Q_SIGNALS
#define explicit
QFile file
[0]
file setFileName("readme.txt")
QFileDialog dialog(this)
[1]
\inmodule QtQuick
Definition qquickitem.h:159