diff options
author | Dominik Haumann <dhaumann@kde.org> | 2014-02-04 19:00:09 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-08 10:56:06 +0100 |
commit | f34b7f42e5c9d2a50da51dbba5fa18467d0262c0 (patch) | |
tree | 69ec0d61f9a6049d2a1efd1ba7ae324f996a1980 | |
parent | 85498fdedefdaaf0a6275bcb123d867a8509d643 (diff) |
QPA fix: allow setting the initially selected name filter (KDE)
In KDE, without this patch, the Q_ASSERT in the following code fragment
fails:
QFileDialog dialog;
QStringList list = QStringList() << "c (*.cpp)" << "h (*.h)";
dialog.setNameFilters(list);
QString filter("h (*.h)");
dialog.selectNameFilter(filter);
dialog.show();
Q_ASSERT(dialog.selectedNameFilter() == filter);
The reason for the fail is that the selectNameFilter() does not properly
propagate the filter to the QPA plugin. So the first part of this patch
adds d->options->setInitiallySelectedNameFilter(filter); in the function
QFileDialog::selectNameFilter().
The second part of this patch makes sure that the initially set name
filter in the QFileDialogOptions "options" is not overwritten in the
helperPrepareShow() function. This is achieved by adding an if(),
following the if() for the initiallySelectedfiles() the line below.
With this patch, the Q_ASSERT() holds true in KDE Framework 5's
file dialog integration.
Change-Id: I15d8c88a0fa3cdc03e3330f3458bbad139a71212
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index cd95b824a6..998866c039 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -627,7 +627,8 @@ void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) options->setInitialDirectory(directory.exists() ? QUrl::fromLocalFile(directory.absolutePath()) : QUrl()); - options->setInitiallySelectedNameFilter(q->selectedNameFilter()); + if (options->initiallySelectedNameFilter().isEmpty()) + options->setInitiallySelectedNameFilter(q->selectedNameFilter()); if (options->initiallySelectedFiles().isEmpty()) options->setInitiallySelectedFiles(userSelectedFiles()); } @@ -1450,6 +1451,7 @@ QStringList QFileDialog::nameFilters() const void QFileDialog::selectNameFilter(const QString &filter) { Q_D(QFileDialog); + d->options->setInitiallySelectedNameFilter(filter); if (!d->usingWidgets()) { d->selectNameFilter_sys(filter); return; |