Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKFILEDIALOGIMPL_P_H
6#define QQUICKFILEDIALOGIMPL_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick/private/qquicklistview_p.h>
20#include <QtQuickTemplates2/private/qquickdialog_p.h>
21
23
25
26class QQuickComboBox;
27class QQuickDialogButtonBox;
28class QQuickTextField;
29class QQuickLabel;
30
31class QQuickFileDialogImplAttached;
33class QQuickFileDialogImplPrivate;
34class QQuickFileNameFilter;
35class QQuickFolderBreadcrumbBar;
36class QQuickSideBar;
37
38class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImpl : public QQuickDialog
39{
40 Q_OBJECT
41 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
42 Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
43 Q_PROPERTY(QStringList nameFilters READ nameFilters NOTIFY nameFiltersChanged FINAL)
44 Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
45 Q_PROPERTY(QString fileName READ fileName WRITE setFileName NOTIFY selectedFileChanged FINAL)
46 Q_PROPERTY(QString currentFolderName READ currentFolderName NOTIFY selectedFileChanged FINAL)
47 QML_NAMED_ELEMENT(FileDialogImpl)
48 QML_ATTACHED(QQuickFileDialogImplAttached)
49 QML_ADDED_IN_VERSION(6, 2)
50 Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>)
51 Q_MOC_INCLUDE(<QtQuickDialogs2QuickImpl/private/qquickfolderbreadcrumbbar_p.h>)
52 Q_MOC_INCLUDE(<QtQuickDialogs2QuickImpl/private/qquicksidebar_p.h>)
53
54public:
55 explicit QQuickFileDialogImpl(QObject *parent = nullptr);
56
57 static QQuickFileDialogImplAttached *qmlAttachedProperties(QObject *object);
58
59 enum class SetReason {
60 // Either user interaction or e.g. a change in ListView's currentIndex after changing its model.
61 External,
62 // As a result of the user setting an initial selectedFile.
63 Internal
64 };
65
66 QUrl currentFolder() const;
67 void setCurrentFolder(const QUrl &currentFolder, SetReason setReason = SetReason::External);
68
69 QUrl selectedFile() const;
70 void setSelectedFile(const QUrl &file);
71 void setInitialCurrentFolderAndSelectedFile(const QUrl &file);
72
73 QSharedPointer<QFileDialogOptions> options() const;
74 void setOptions(const QSharedPointer<QFileDialogOptions> &options);
75
76 QStringList nameFilters() const;
77 void resetNameFilters();
78
79 QQuickFileNameFilter *selectedNameFilter() const;
80
81 void setAcceptLabel(const QString &label);
82 void setRejectLabel(const QString &label);
83
84 QString fileName() const;
85 void setFileName(const QString &fileName);
86
87 QString currentFolderName() const;
88
89public Q_SLOTS:
90 void selectNameFilter(const QString &filter);
91
92Q_SIGNALS:
93 void currentFolderChanged(const QUrl &folderUrl);
94 void selectedFileChanged(const QUrl &selectedFileUrl);
95 void nameFiltersChanged();
96 void fileSelected(const QUrl &fileUrl);
97 void filterSelected(const QString &filter);
98
99private:
100 void componentComplete() override;
101 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
102
103 Q_DISABLE_COPY(QQuickFileDialogImpl)
104 Q_DECLARE_PRIVATE(QQuickFileDialogImpl)
105};
106
107class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImplAttached : public QObject
108{
109 Q_OBJECT
110 Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox WRITE setButtonBox NOTIFY buttonBoxChanged FINAL)
111 Q_PROPERTY(QQuickComboBox *nameFiltersComboBox READ nameFiltersComboBox WRITE setNameFiltersComboBox NOTIFY nameFiltersComboBoxChanged)
112 Q_PROPERTY(QQuickListView *fileDialogListView READ fileDialogListView WRITE setFileDialogListView NOTIFY fileDialogListViewChanged)
113 Q_PROPERTY(QQuickFolderBreadcrumbBar *breadcrumbBar READ breadcrumbBar WRITE setBreadcrumbBar NOTIFY breadcrumbBarChanged)
114 Q_PROPERTY(QQuickLabel *fileNameLabel READ fileNameLabel WRITE setFileNameLabel NOTIFY fileNameLabelChanged FINAL)
115 Q_PROPERTY(QQuickTextField *fileNameTextField READ fileNameTextField WRITE setFileNameTextField NOTIFY fileNameTextFieldChanged FINAL)
116 Q_PROPERTY(QQuickDialog *overwriteConfirmationDialog READ overwriteConfirmationDialog WRITE setOverwriteConfirmationDialog NOTIFY overwriteConfirmationDialogChanged FINAL)
117 Q_PROPERTY(QQuickSideBar *sideBar READ sideBar WRITE setSideBar NOTIFY sideBarChanged FINAL)
118 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickdialogbuttonbox_p.h>)
119 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquickcombobox_p.h>)
120 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicktextfield_p.h>)
121 Q_MOC_INCLUDE(<QtQuickTemplates2/private/qquicklabel_p.h>)
122
123public:
124 explicit QQuickFileDialogImplAttached(QObject *parent = nullptr);
125
126 QQuickDialogButtonBox *buttonBox() const;
127 void setButtonBox(QQuickDialogButtonBox *buttonBox);
128
129 QQuickComboBox *nameFiltersComboBox() const;
130 void setNameFiltersComboBox(QQuickComboBox *nameFiltersComboBox);
131
132 QString selectedNameFilter() const;
133 void selectNameFilter(const QString &filter);
134
135 QQuickListView *fileDialogListView() const;
136 void setFileDialogListView(QQuickListView *fileDialogListView);
137
138 QQuickFolderBreadcrumbBar *breadcrumbBar() const;
139 void setBreadcrumbBar(QQuickFolderBreadcrumbBar *breadcrumbBar);
140
141 QQuickLabel *fileNameLabel() const;
142 void setFileNameLabel(QQuickLabel *fileNameLabel);
143
144 QQuickTextField *fileNameTextField() const;
145 void setFileNameTextField(QQuickTextField *fileNameTextField);
146
147 QQuickDialog *overwriteConfirmationDialog() const;
148 void setOverwriteConfirmationDialog(QQuickDialog *dialog);
149
150 QQuickSideBar *sideBar() const;
151 void setSideBar(QQuickSideBar *sideBar);
152
153Q_SIGNALS:
154 void buttonBoxChanged();
155 void nameFiltersComboBoxChanged();
156 void fileDialogListViewChanged();
157 void breadcrumbBarChanged();
158 void fileNameLabelChanged();
159 void fileNameTextFieldChanged();
160 void overwriteConfirmationDialogChanged();
161 Q_REVISION(6, 9) void sideBarChanged();
162
163private:
164 Q_DISABLE_COPY(QQuickFileDialogImplAttached)
165 Q_DECLARE_PRIVATE(QQuickFileDialogImplAttached)
166};
167
168QT_END_NAMESPACE
169
170#endif // QQUICKFILEDIALOGIMPL_P_H
bool acceptKeyClick(Qt::Key key) const override
void handleEventPoint(QPointerEvent *event, QEventPoint &point) override
void handleDrag(QQuickDragEvent *event)
QQuickFileDialogImpl * getFileDialogImpl() const
bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point) override
Returns true if the given point (as part of event) could be relevant at all to this handler,...
void handleDrop(QQuickDragEvent *event)