Review Request 115478: Add QFileDialog unit autotest for filters (which reveals a QPA bug)
Dominik Haumann
dhaumann at kde.org
Sun Mar 9 18:11:51 UTC 2014
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/115478/
-----------------------------------------------------------
(Updated March 9, 2014, 6:11 p.m.)
Review request for KDE Frameworks, Àlex Fiestas and Gregor Mi.
Changes
-------
Updated diff that implements the "initially selected name filter" in KDE's frameworks integration module.
Next, it adds a unit test for this.
The Qt patch was accepted several weeks ago, so it will work on build.kde.org.
Repository: frameworkintegration
Description
-------
The following QPA integration does not work as expected:
QStringList nameFilterList = QStringList() << "c (*.cpp)" << "h (*.h)";
dialog.setNameFilters(nameFilterList);
QString selectNameFilter("h (*.h)");
dialog.selectNameFilter(selectNameFilter);
// QCOMPARE(dialog.selectedNameFilter(), selectNameFilter); // (1) always fails, no matter what
dialog.show();
QCOMPARE(dialog.selectedNameFilter(), selectNameFilter); // (2) currently also fails, Qt patch required
The problem is described in detail in:
http://mail.kde.org/pipermail/kde-frameworks-devel/2014-February/010691.html
The Qt patches that make (2) work are as follows:
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index da026d2..72b2310 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());
}
@@ -1447,6 +1448,7 @@ void QFileDialog::selectNameFilter(const QString &filter)
{
Q_D(QFileDialog);
if (!d->usingWidgets()) {
+ d->options->setInitiallySelectedNameFilter(filter);
d->selectNameFilter_sys(filter);
return;
}
However, the QCOMPARE in (1) is still an open issue. And no fix in sight...
Ok to commit this to frameworksintegration (and therewith make it unstable?)
Diffs (updated)
-----
autotests/CMakeLists.txt f76ab15
autotests/kfiledialog_unittest.cpp PRE-CREATION
src/platformtheme/kdeplatformfiledialoghelper.cpp c82b821
Diff: https://git.reviewboard.kde.org/r/115478/diff/
Testing
-------
The attached unit test currently fails due to a bug in the Qt QPA.
With the Qt patch above, (2) in the unit test passes, so one is able to call QFileDialog::selectNameFilter().
However, (1) remains broken.
Thanks,
Dominik Haumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140309/8b73ccd1/attachment.html>
More information about the Kde-frameworks-devel
mailing list