diff options
author | David Faure <david.faure@kdab.com> | 2015-05-09 14:12:28 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2015-07-17 14:29:47 +0000 |
commit | 5443da6c2795255db55697471190b3eba16b28dc (patch) | |
tree | 4c6d0d26eb7ff2065f77bf70328563a476c71f31 /src/widgets | |
parent | 4e4b16dc1789f660f25bea3a9b9111053de2cc61 (diff) |
QFileDialog: add setSupportedSchemes and pass it along to the QPA.
This also finishes the implementation of the static methods which
were being passed a supportedSchemes argument but weren't using it.
Now they can pass it along to the QFileDialog instance, which then
passes it to the helper used by the QPA implementation of the file
dialog. The default implementation only supports local files and
can therefore ignore this, but other implementations can use this
argument to restrict the protocols allowed to the user.
[ChangeLog][Widgets][QFileDialog] Add supportedSchemes property.
Change-Id: I5235f70e785da1c06866a8355ef98f571890c4a2
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 36 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog.h | 4 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 45f41bb0d2..86ca64d82a 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1700,6 +1700,30 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) d->retranslateWindowTitle(); } +/*! + \property QFileDialog::supportedSchemes + \brief the URL schemes that the file dialog should allow navigating to. + \since 5.6 + + Setting this property allows to restrict the type of URLs the + user will be able to select. It is a way for the application to declare + the protocols it will support to fetch the file content. An empty list + means that no restriction is applied (the default). + Supported for local files ("file" scheme) is implicit and always enabled; + it is not necessary to include it in the restriction. +*/ + +void QFileDialog::setSupportedSchemes(const QStringList &schemes) +{ + Q_D(QFileDialog); + d->options->setSupportedSchemes(schemes); +} + +QStringList QFileDialog::supportedSchemes() const +{ + return d_func()->options->supportedSchemes(); +} + /* Returns the file system model index that is the root index in the views @@ -2114,8 +2138,6 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent, Options options, const QStringList &supportedSchemes) { - Q_UNUSED(supportedSchemes); // TODO - QFileDialogArgs args; args.parent = parent; args.caption = caption; @@ -2126,6 +2148,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent, args.options = options; QFileDialog dialog(args); + dialog.setSupportedSchemes(supportedSchemes); if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); if (dialog.exec() == QDialog::Accepted) { @@ -2237,8 +2260,6 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent, Options options, const QStringList &supportedSchemes) { - Q_UNUSED(supportedSchemes); - QFileDialogArgs args; args.parent = parent; args.caption = caption; @@ -2249,6 +2270,7 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent, args.options = options; QFileDialog dialog(args); + dialog.setSupportedSchemes(supportedSchemes); if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); if (dialog.exec() == QDialog::Accepted) { @@ -2356,8 +2378,6 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent, Options options, const QStringList &supportedSchemes) { - Q_UNUSED(supportedSchemes); - QFileDialogArgs args; args.parent = parent; args.caption = caption; @@ -2368,6 +2388,7 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent, args.options = options; QFileDialog dialog(args); + dialog.setSupportedSchemes(supportedSchemes); dialog.setAcceptMode(AcceptSave); if (selectedFilter && !selectedFilter->isEmpty()) dialog.selectNameFilter(*selectedFilter); @@ -2461,8 +2482,6 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent, Options options, const QStringList &supportedSchemes) { - Q_UNUSED(supportedSchemes); - QFileDialogArgs args; args.parent = parent; args.caption = caption; @@ -2471,6 +2490,7 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent, args.options = options; QFileDialog dialog(args); + dialog.setSupportedSchemes(supportedSchemes); if (dialog.exec() == QDialog::Accepted) return dialog.selectedUrls().value(0); return QUrl(); diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index 6bbeb3817a..bba8c5f3c7 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -66,6 +66,7 @@ class Q_WIDGETS_EXPORT QFileDialog : public QDialog Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible WRITE setNameFilterDetailsVisible DESIGNABLE false) Q_PROPERTY(Options options READ options WRITE setOptions) + Q_PROPERTY(QStringList supportedSchemes READ supportedSchemes WRITE setSupportedSchemes) public: enum ViewMode { Detail, List }; @@ -167,6 +168,9 @@ public: void setLabelText(DialogLabel label, const QString &text); QString labelText(DialogLabel label) const; + void setSupportedSchemes(const QStringList &schemes); + QStringList supportedSchemes() const; + #ifndef QT_NO_PROXYMODEL void setProxyModel(QAbstractProxyModel *model); QAbstractProxyModel *proxyModel() const; |