Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qfiledialog.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QFILEDIALOG_H
0005 #define QFILEDIALOG_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtCore/qdir.h>
0009 #include <QtCore/qstring.h>
0010 #include <QtCore/qurl.h>
0011 #include <QtWidgets/qdialog.h>
0012 
0013 #include <functional>
0014 
0015 QT_REQUIRE_CONFIG(filedialog);
0016 
0017 QT_BEGIN_NAMESPACE
0018 
0019 class QModelIndex;
0020 class QItemSelection;
0021 struct QFileDialogArgs;
0022 class QFileDialogPrivate;
0023 class QAbstractFileIconProvider;
0024 class QAbstractItemDelegate;
0025 class QAbstractProxyModel;
0026 
0027 class Q_WIDGETS_EXPORT QFileDialog : public QDialog
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
0031     Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
0032     Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
0033     Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
0034     Q_PROPERTY(Options options READ options WRITE setOptions)
0035     Q_PROPERTY(QStringList supportedSchemes READ supportedSchemes WRITE setSupportedSchemes)
0036 
0037 public:
0038     enum ViewMode { Detail, List };
0039     Q_ENUM(ViewMode)
0040     enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles };
0041     Q_ENUM(FileMode)
0042     enum AcceptMode { AcceptOpen, AcceptSave };
0043     Q_ENUM(AcceptMode)
0044     enum DialogLabel { LookIn, FileName, FileType, Accept, Reject };
0045 
0046     // keep this in sync with QFileDialogOption::FileDialogOptions
0047     enum Option
0048     {
0049         ShowDirsOnly                = 0x00000001,
0050         DontResolveSymlinks         = 0x00000002,
0051         DontConfirmOverwrite        = 0x00000004,
0052         DontUseNativeDialog         = 0x00000008,
0053         ReadOnly                    = 0x00000010,
0054         HideNameFilterDetails       = 0x00000020,
0055         DontUseCustomDirectoryIcons = 0x00000040
0056     };
0057     Q_ENUM(Option)
0058     Q_DECLARE_FLAGS(Options, Option)
0059     Q_FLAG(Options)
0060 
0061     QFileDialog(QWidget *parent, Qt::WindowFlags f);
0062     explicit QFileDialog(QWidget *parent = nullptr,
0063                          const QString &caption = QString(),
0064                          const QString &directory = QString(),
0065                          const QString &filter = QString());
0066     ~QFileDialog();
0067 
0068     void setDirectory(const QString &directory);
0069     inline void setDirectory(const QDir &directory);
0070     QDir directory() const;
0071 
0072     void setDirectoryUrl(const QUrl &directory);
0073     QUrl directoryUrl() const;
0074 
0075     void selectFile(const QString &filename);
0076     QStringList selectedFiles() const;
0077 
0078     void selectUrl(const QUrl &url);
0079     QList<QUrl> selectedUrls() const;
0080 
0081     void setNameFilter(const QString &filter);
0082     void setNameFilters(const QStringList &filters);
0083     QStringList nameFilters() const;
0084     void selectNameFilter(const QString &filter);
0085     QString selectedMimeTypeFilter() const;
0086     QString selectedNameFilter() const;
0087 
0088 #if QT_CONFIG(mimetype)
0089     void setMimeTypeFilters(const QStringList &filters);
0090     QStringList mimeTypeFilters() const;
0091     void selectMimeTypeFilter(const QString &filter);
0092 #endif
0093 
0094     QDir::Filters filter() const;
0095     void setFilter(QDir::Filters filters);
0096 
0097     void setViewMode(ViewMode mode);
0098     ViewMode viewMode() const;
0099 
0100     void setFileMode(FileMode mode);
0101     FileMode fileMode() const;
0102 
0103     void setAcceptMode(AcceptMode mode);
0104     AcceptMode acceptMode() const;
0105 
0106     void setSidebarUrls(const QList<QUrl> &urls);
0107     QList<QUrl> sidebarUrls() const;
0108 
0109     QByteArray saveState() const;
0110     bool restoreState(const QByteArray &state);
0111 
0112     void setDefaultSuffix(const QString &suffix);
0113     QString defaultSuffix() const;
0114 
0115     void setHistory(const QStringList &paths);
0116     QStringList history() const;
0117 
0118     void setItemDelegate(QAbstractItemDelegate *delegate);
0119     QAbstractItemDelegate *itemDelegate() const;
0120 
0121     void setIconProvider(QAbstractFileIconProvider *provider);
0122     QAbstractFileIconProvider *iconProvider() const;
0123 
0124     void setLabelText(DialogLabel label, const QString &text);
0125     QString labelText(DialogLabel label) const;
0126 
0127     void setSupportedSchemes(const QStringList &schemes);
0128     QStringList supportedSchemes() const;
0129 
0130 #if QT_CONFIG(proxymodel)
0131     void setProxyModel(QAbstractProxyModel *model);
0132     QAbstractProxyModel *proxyModel() const;
0133 #endif
0134 
0135     void setOption(Option option, bool on = true);
0136     bool testOption(Option option) const;
0137     void setOptions(Options options);
0138     Options options() const;
0139 
0140     using QDialog::open;
0141     void open(QObject *receiver, const char *member);
0142     void setVisible(bool visible) override;
0143 
0144 Q_SIGNALS:
0145     void fileSelected(const QString &file);
0146     void filesSelected(const QStringList &files);
0147     void currentChanged(const QString &path);
0148     void directoryEntered(const QString &directory);
0149 
0150     void urlSelected(const QUrl &url);
0151     void urlsSelected(const QList<QUrl> &urls);
0152     void currentUrlChanged(const QUrl &url);
0153     void directoryUrlEntered(const QUrl &directory);
0154 
0155     void filterSelected(const QString &filter);
0156 
0157 public:
0158 
0159     static QString getOpenFileName(QWidget *parent = nullptr,
0160                                    const QString &caption = QString(),
0161                                    const QString &dir = QString(),
0162                                    const QString &filter = QString(),
0163                                    QString *selectedFilter = nullptr,
0164                                    Options options = Options());
0165 
0166     static QUrl getOpenFileUrl(QWidget *parent = nullptr,
0167                                const QString &caption = QString(),
0168                                const QUrl &dir = QUrl(),
0169                                const QString &filter = QString(),
0170                                QString *selectedFilter = nullptr,
0171                                Options options = Options(),
0172                                const QStringList &supportedSchemes = QStringList());
0173 
0174     static QString getSaveFileName(QWidget *parent = nullptr,
0175                                    const QString &caption = QString(),
0176                                    const QString &dir = QString(),
0177                                    const QString &filter = QString(),
0178                                    QString *selectedFilter = nullptr,
0179                                    Options options = Options());
0180 
0181     static QUrl getSaveFileUrl(QWidget *parent = nullptr,
0182                                const QString &caption = QString(),
0183                                const QUrl &dir = QUrl(),
0184                                const QString &filter = QString(),
0185                                QString *selectedFilter = nullptr,
0186                                Options options = Options(),
0187                                const QStringList &supportedSchemes = QStringList());
0188 
0189     static QString getExistingDirectory(QWidget *parent = nullptr,
0190                                         const QString &caption = QString(),
0191                                         const QString &dir = QString(),
0192                                         Options options = ShowDirsOnly);
0193 
0194     static QUrl getExistingDirectoryUrl(QWidget *parent = nullptr,
0195                                         const QString &caption = QString(),
0196                                         const QUrl &dir = QUrl(),
0197                                         Options options = ShowDirsOnly,
0198                                         const QStringList &supportedSchemes = QStringList());
0199 
0200     static QStringList getOpenFileNames(QWidget *parent = nullptr,
0201                                         const QString &caption = QString(),
0202                                         const QString &dir = QString(),
0203                                         const QString &filter = QString(),
0204                                         QString *selectedFilter = nullptr,
0205                                         Options options = Options());
0206 
0207     static QList<QUrl> getOpenFileUrls(QWidget *parent = nullptr,
0208                                        const QString &caption = QString(),
0209                                        const QUrl &dir = QUrl(),
0210                                        const QString &filter = QString(),
0211                                        QString *selectedFilter = nullptr,
0212                                        Options options = Options(),
0213                                        const QStringList &supportedSchemes = QStringList());
0214 
0215     static void getOpenFileContent(const QString &nameFilter,
0216                                    const std::function<void(const QString &, const QByteArray &)> &fileContentsReady,
0217                                    QWidget *parent= nullptr);
0218 
0219     static void saveFileContent(const QByteArray &fileContent,
0220                                 const QString &fileNameHint,
0221                                 QWidget *parent = nullptr);
0222 
0223 #if QT_WIDGETS_REMOVED_SINCE(6, 7)
0224     static void getOpenFileContent(const QString &nameFilter,
0225                                    const std::function<void(const QString &, const QByteArray &)> &fileContentsReady);
0226     static void saveFileContent(const QByteArray &fileContent,
0227                                 const QString &fileNameHint = QString());
0228 #endif
0229 
0230 
0231 protected:
0232     QFileDialog(const QFileDialogArgs &args);
0233     void done(int result) override;
0234     void accept() override;
0235     void changeEvent(QEvent *e) override;
0236 
0237 private:
0238     Q_DECLARE_PRIVATE(QFileDialog)
0239     Q_DISABLE_COPY(QFileDialog)
0240 
0241     friend class QPlatformDialogHelper;
0242 };
0243 
0244 inline void QFileDialog::setDirectory(const QDir &adirectory)
0245 { setDirectory(adirectory.absolutePath()); }
0246 
0247 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDialog::Options)
0248 
0249 QT_END_NAMESPACE
0250 
0251 #endif // QFILEDIALOG_H