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
21#include "qtquickdialogs2quickimplglobal_p.h"
22
23QT_BEGIN_NAMESPACE
24
25class QQuickComboBox;
26class QQuickDialogButtonBox;
27class QQuickTextField;
28class QQuickLabel;
29
30class QQuickFileDialogImplAttached;
31class QQuickFileDialogImplAttachedPrivate;
32class QQuickFileDialogImplPrivate;
33class QQuickFileNameFilter;
34class QQuickFolderBreadcrumbBar;
35
36class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImpl : public QQuickDialog
37{
38 Q_OBJECT
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)
46 QML_ATTACHED(QQuickFileDialogImplAttached)
47 QML_ADDED_IN_VERSION(6, 2)
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
89Q_SIGNALS:
90 void currentFolderChanged(const QUrl &folderUrl);
91 void selectedFileChanged(const QUrl &selectedFileUrl);
92 void nameFiltersChanged();
93 void fileSelected(const QUrl &fileUrl);
94 void filterSelected(const QString &filter);
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{
106 Q_OBJECT
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:
120 explicit QQuickFileDialogImplAttached(QObject *parent = nullptr);
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
146Q_SIGNALS:
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
160QT_END_NAMESPACE
161
162#endif // QQUICKFILEDIALOGIMPL_P_H
163

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtdeclarative/src/quickdialogs/quickdialogsquickimpl/qquickfiledialogimpl_p.h