summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-07-08 16:44:41 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-07-10 11:48:55 +0200
commit551b9fc2aaf254a768a4d7f43d274b1f53f33237 (patch)
tree829a0ad1a3d877159f4de6d72abc1617fdd1968e /tests
parent37e3e381376013ef1fa27d69dd6fe6fe5cc2669a (diff)
Fix auto completion in QFileDialog on Windows
Amends c0b3c06a7d4f6a2f90742e8dc81c898082a70416. The QCompleter used by QFileDialog uses starts-with matching of the path parts, for all parts of the path. It uses the EditRole of the underlying model for the data to match. The path parts used for a path on Windows are "C:", "Users", "etc...", and then finally whatever input has been typed so far. If we try to match that against a starts-with rule against "Local Disk (C:)", then it will fail and the completer will never have anything to show. So, for the EditRole, return just the volume drive letter as we did before c0b3c06a7d4f6a2f90742e8dc81c898082a70416, not the volume name. Neither can be edited anyway. This happens to then match the native file dialog behavior, which doesn't complete "L" to "Local Disk (C:)" if the Computer contents (ie. volumes) are shown. Augment the QCompleter test case to cover that scenario (it already has everything set up for this particular combination, even though we are actually testing QFileSystemModel returning the correct data). Fixes: QTBUG-94799 Task-number: QTBUG-78043 Change-Id: I14844d91601e9b16dc07cff2ca48713acb7cdd09 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit d2e88b8094db0bda6b3ab89172352861ae18d301) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
index 89c4a74739..364bc36dff 100644
--- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp
@@ -113,6 +113,8 @@ private slots:
#endif
void fileSystemModel_data();
void fileSystemModel();
+ void fileDialog_data();
+ void fileDialog();
void changingModel_data();
void changingModel();
@@ -695,7 +697,26 @@ void tst_QCompleter::fileSystemModel()
#ifdef Q_OS_WINRT
QSKIP("WinRT cannot access directories outside of the application's sandbox");
#endif
- //QFileSystemModel is assync.
+ //QFileSystemModel is async.
+ filter(true);
+}
+
+/*!
+ In the file dialog, the completer uses the EditRole.
+ See QTBUG-94799
+*/
+void tst_QCompleter::fileDialog_data()
+{
+ fileSystemModel_data();
+ completer->setCompletionRole(Qt::EditRole);
+}
+
+void tst_QCompleter::fileDialog()
+{
+#ifdef Q_OS_WINRT
+ QSKIP("WinRT cannot access directories outside of the application's sandbox");
+#endif
+ //QFileSystemModel is async.
filter(true);
}