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
qquickfiledialog_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 QQUICKFILEDIALOG_P_H
6#define QQUICKFILEDIALOG_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 <QtCore/qurl.h>
20#include <QtQml/qqml.h>
21
23
25
26class QQuickFileNameFilter;
27
28class Q_QUICKDIALOGS2_EXPORT QQuickFileDialog : public QQuickAbstractDialog
29{
30 Q_OBJECT
31 Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode NOTIFY fileModeChanged FINAL)
32 Q_PROPERTY(QUrl selectedFile READ selectedFile WRITE setSelectedFile NOTIFY selectedFileChanged FINAL)
33 Q_PROPERTY(QList<QUrl> selectedFiles READ selectedFiles NOTIFY selectedFilesChanged FINAL)
34 Q_PROPERTY(QUrl currentFile READ currentFile WRITE setCurrentFile NOTIFY currentFileChanged FINAL)
35 Q_PROPERTY(QList<QUrl> currentFiles READ currentFiles WRITE setCurrentFiles NOTIFY currentFilesChanged FINAL)
36 Q_PROPERTY(QUrl currentFolder READ currentFolder WRITE setCurrentFolder NOTIFY currentFolderChanged FINAL)
37 Q_PROPERTY(QFileDialogOptions::FileDialogOptions options READ options WRITE setOptions RESET resetOptions NOTIFY optionsChanged FINAL)
38 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters RESET resetNameFilters NOTIFY nameFiltersChanged FINAL)
39 Q_PROPERTY(QQuickFileNameFilter *selectedNameFilter READ selectedNameFilter CONSTANT)
40 Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix RESET resetDefaultSuffix NOTIFY defaultSuffixChanged FINAL)
41 Q_PROPERTY(QString acceptLabel READ acceptLabel WRITE setAcceptLabel RESET resetAcceptLabel NOTIFY acceptLabelChanged FINAL)
42 Q_PROPERTY(QString rejectLabel READ rejectLabel WRITE setRejectLabel RESET resetRejectLabel NOTIFY rejectLabelChanged FINAL)
43 QML_NAMED_ELEMENT(FileDialog)
44 QML_EXTENDED_NAMESPACE(QFileDialogOptions)
45 QML_ADDED_IN_VERSION(6, 2)
46 Q_MOC_INCLUDE(<QtQuickDialogs2Utils/private/qquickfilenamefilter_p.h>)
47
48public:
49 explicit QQuickFileDialog(QObject *parent = nullptr);
50
51 enum FileMode {
52 OpenFile,
53 OpenFiles,
54 SaveFile,
55 OpenUrl,
56 OpenUrls,
57 SaveUrl,
58 };
59 Q_ENUM(FileMode)
60
61 FileMode fileMode() const;
62 void setFileMode(FileMode fileMode);
63
64 QUrl selectedFile() const;
65 void setSelectedFile(const QUrl &selectedFile);
66
67 QList<QUrl> selectedFiles() const;
68
69 QUrl currentFile() const;
70 void setCurrentFile(const QUrl &file);
71
72 QList<QUrl> currentFiles() const;
73 void setCurrentFiles(const QList<QUrl> &currentFiles);
74
75 QUrl currentFolder() const;
76 void setCurrentFolder(const QUrl &currentFolder);
77
78 QFileDialogOptions::FileDialogOptions options() const;
79 void setOptions(QFileDialogOptions::FileDialogOptions options);
80 void resetOptions();
81
82 QStringList nameFilters() const;
83 void setNameFilters(const QStringList &filters);
84 void resetNameFilters();
85
86 QQuickFileNameFilter *selectedNameFilter() const;
87
88 QString defaultSuffix() const;
89 void setDefaultSuffix(const QString &suffix);
90 void resetDefaultSuffix();
91
92 QString acceptLabel() const;
93 void setAcceptLabel(const QString &label);
94 void resetAcceptLabel();
95
96 QString rejectLabel() const;
97 void setRejectLabel(const QString &label);
98 void resetRejectLabel();
99
100Q_SIGNALS:
101 void fileModeChanged();
102 void selectedFileChanged();
103 void selectedFilesChanged();
104 void currentFileChanged();
105 void currentFilesChanged();
106 void currentFolderChanged();
107 void optionsChanged();
108 void nameFiltersChanged();
109 void defaultSuffixChanged();
110 void acceptLabelChanged();
111 void rejectLabelChanged();
112
113protected:
114 bool useNativeDialog() const override;
115 void onCreate(QPlatformDialogHelper *dialog) override;
116 void onShow(QPlatformDialogHelper *dialog) override;
117 void onHide(QPlatformDialogHelper *dialog) override;
118 void accept() override;
119
120private:
121 QUrl addDefaultSuffix(const QUrl &file) const;
122 QList<QUrl> addDefaultSuffixes(const QList<QUrl> &files) const;
123
124 void setSelectedFiles(const QList<QUrl> &selectedFiles);
125
126 FileMode m_fileMode;
127 QList<QUrl> m_selectedFiles;
128 QSharedPointer<QFileDialogOptions> m_options;
129 mutable QQuickFileNameFilter *m_selectedNameFilter;
130};
131
132QT_END_NAMESPACE
133
134#endif // QQUICKFILEDIALOG_P_H
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)