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
26QT_BEGIN_NAMESPACE
27
28class QQuickFileNameFilter;
29
30class Q_QUICKDIALOGS2QUICKIMPL_PRIVATE_EXPORT QQuickFileDialogImplPrivate : public QQuickDialogPrivate
31{
32public:
33 Q_DECLARE_PUBLIC(QQuickFileDialogImpl)
34
35 QQuickFileDialogImplPrivate();
36
37 static QQuickFileDialogImplPrivate *get(QQuickFileDialogImpl *dialog)
38 {
39 return dialog->d_func();
40 }
41
42 QQuickFileDialogImplAttached *attachedOrWarn();
43
44 void setNameFilters(const QStringList &filters);
45
46 void updateEnabled();
47 void updateSelectedFile(const QString &oldFolderPath);
48 static QDir::SortFlags fileListSortFlags();
49 static QFileInfoList fileList(const QDir &dir);
50 void setFileDialogListViewCurrentIndex(int newCurrentIndex);
51 void tryUpdateFileDialogListViewCurrentIndex(int newCurrentIndex);
52 void fileDialogListViewCountChanged();
53
54 void handleAccept() override;
55 void handleClick(QQuickAbstractButton *button) override;
56
57 QSharedPointer<QFileDialogOptions> options;
58 QUrl currentFolder;
59 QUrl selectedFile;
60 QStringList nameFilters;
61 mutable QQuickFileNameFilter *selectedNameFilter = nullptr;
62 QString acceptLabel;
63 QString rejectLabel;
64 bool setCurrentIndexToInitiallySelectedFile = false;
65 QFileInfoList cachedFileList;
66 int pendingCurrentIndexToSet = -1;
67};
68
69class QQuickFileDialogImplAttachedPrivate : public QObjectPrivate
70{
71 void nameFiltersComboBoxItemActivated(int index);
72 void fileDialogListViewCurrentIndexChanged();
73 void fileNameChangedByUser();
74
75public:
76 Q_DECLARE_PUBLIC(QQuickFileDialogImplAttached)
77
78 QPointer<QQuickDialogButtonBox> buttonBox;
79 QPointer<QQuickComboBox> nameFiltersComboBox;
80 QPointer<QQuickListView> fileDialogListView;
81 QPointer<QQuickFolderBreadcrumbBar> breadcrumbBar;
82 QPointer<QQuickLabel> fileNameLabel;
83 QPointer<QQuickTextField> fileNameTextField;
84};
85
86QT_END_NAMESPACE
87
88#endif // QQUICKFILEDIALOG_P_P_H
89

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