diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-07-08 16:44:41 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-07-09 00:48:44 +0200 |
commit | d2e88b8094db0bda6b3ab89172352861ae18d301 (patch) | |
tree | 47519e28cdbfc8b099116962bb24555e1194fd03 /tests/auto/widgets/util | |
parent | f33d11796ff91bfd0323e6bccd03b4cf16b1f371 (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
Pick-to: 5.15 6.2 6.1
Change-Id: I14844d91601e9b16dc07cff2ca48713acb7cdd09
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/widgets/util')
-rw-r--r-- | tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 7de37875b2..51a75573a4 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -110,6 +110,8 @@ private slots: void fileSystemModel_data(); void fileSystemModel(); + void fileDialog_data(); + void fileDialog(); void changingModel_data(); void changingModel(); @@ -626,7 +628,23 @@ void tst_QCompleter::fileSystemModel_data() void tst_QCompleter::fileSystemModel() { - //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() +{ + //QFileSystemModel is async. filter(true); } |