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 QQUICKFILEDIALOG_P_P_H |
5 | #define QQUICKFILEDIALOG_P_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 <QtQuickTemplates2/private/qquickcombobox_p.h> |
19 | #include <QtQuickTemplates2/private/qquickdialog_p_p.h> |
20 | #include <QtQuickTemplates2/private/qquickdialogbuttonbox_p.h> |
21 | #include <QtQuickTemplates2/private/qquicklabel_p.h> |
22 | #include <QtQuickTemplates2/private/qquicktextfield_p.h> |
23 | |
24 | #include "qquickfiledialogimpl_p.h" |
25 | |
26 | #include <QtCore/qpointer.h> |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | class QQuickFileNameFilter; |
31 | |
32 | class Q_QUICKDIALOGS2QUICKIMPL_EXPORT QQuickFileDialogImplPrivate : public QQuickDialogPrivate |
33 | { |
34 | public: |
35 | Q_DECLARE_PUBLIC(QQuickFileDialogImpl) |
36 | |
37 | QQuickFileDialogImplPrivate(); |
38 | |
39 | static QQuickFileDialogImplPrivate *get(QQuickFileDialogImpl *dialog) |
40 | { |
41 | return dialog->d_func(); |
42 | } |
43 | |
44 | QQuickFileDialogImplAttached *attachedOrWarn(); |
45 | |
46 | void setNameFilters(const QStringList &filters); |
47 | |
48 | void updateEnabled(); |
49 | void updateSelectedFile(const QString &oldFolderPath); |
50 | void updateFileNameTextEdit(); |
51 | static QDir::SortFlags fileListSortFlags(); |
52 | static QFileInfoList fileList(const QDir &dir); |
53 | void setFileDialogListViewCurrentIndex(int newCurrentIndex); |
54 | void tryUpdateFileDialogListViewCurrentIndex(int newCurrentIndex); |
55 | void fileDialogListViewCountChanged(); |
56 | |
57 | void handleAccept() override; |
58 | void handleClick(QQuickAbstractButton *button) override; |
59 | void selectFile(); |
60 | |
61 | QSharedPointer<QFileDialogOptions> options; |
62 | QUrl currentFolder; |
63 | QUrl selectedFile; |
64 | QQuickAbstractButton *lastButtonClicked = nullptr; |
65 | QStringList nameFilters; |
66 | mutable QQuickFileNameFilter *selectedNameFilter = nullptr; |
67 | QString acceptLabel; |
68 | QString rejectLabel; |
69 | bool setCurrentIndexToInitiallySelectedFile = false; |
70 | QFileInfoList cachedFileList; |
71 | int pendingCurrentIndexToSet = -1; |
72 | }; |
73 | |
74 | class QQuickFileDialogImplAttachedPrivate : public QObjectPrivate |
75 | { |
76 | void nameFiltersComboBoxItemActivated(int index); |
77 | void fileDialogListViewCurrentIndexChanged(); |
78 | void fileNameEditedByUser(); |
79 | void fileNameEditingByUserFinished(); |
80 | |
81 | public: |
82 | Q_DECLARE_PUBLIC(QQuickFileDialogImplAttached) |
83 | |
84 | QPointer<QQuickDialogButtonBox> buttonBox; |
85 | QPointer<QQuickComboBox> nameFiltersComboBox; |
86 | QPointer<QQuickListView> fileDialogListView; |
87 | QPointer<QQuickFolderBreadcrumbBar> breadcrumbBar; |
88 | QPointer<QQuickLabel> fileNameLabel; |
89 | QPointer<QQuickTextField> fileNameTextField; |
90 | QPointer<QQuickDialog> overwriteConfirmationDialog; |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif // QQUICKFILEDIALOG_P_P_H |
96 | |