diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-07-12 16:02:53 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-07-13 13:45:44 +0000 |
commit | 9131f6e56139924162778c6c0538dda58d839bbb (patch) | |
tree | 67b226fc8f98326592e30c1c36222aafe6af2ca7 /tests/auto/widgets/util | |
parent | 4397a1b26c244dc4cd0d3826e0c4135ec9003914 (diff) |
QCompleter::setModel(): Restore completion role
When setting a QFileSystemModel as model, the completion role
is set to QFileSystemModel::FileNameRole. This needs to be reset
to the default Qt::EditRole when setting another model.
Task-number: QTBUG-54642
Change-Id: Ie78d5d417e008ad05a2f995bdbc218b3ad1bc49c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'tests/auto/widgets/util')
-rw-r--r-- | tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index e8ac9aa5d2..86a0bdf901 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -291,8 +291,8 @@ retry: // Testing get/set functions void tst_QCompleter::getSetCheck() { - QStandardItemModel model(3,3); - QCompleter completer(&model); + QStandardItemModel standardItemModel(3,3); + QCompleter completer(&standardItemModel); // QString QCompleter::completionPrefix() // void QCompleter::setCompletionPrefix(QString) @@ -352,6 +352,21 @@ void tst_QCompleter::getSetCheck() QCOMPARE(completer.wrapAround(), true); // default value completer.setWrapAround(false); QCOMPARE(completer.wrapAround(), false); + +#ifndef QT_NO_FILESYSTEMMODEL + // QTBUG-54642, changing from QFileSystemModel to another model should restore role. + completer.setCompletionRole(Qt::EditRole); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); // default value + QFileSystemModel fileSystemModel; + completer.setModel(&fileSystemModel); + QCOMPARE(completer.completionRole(), static_cast<int>(QFileSystemModel::FileNameRole)); + completer.setModel(&standardItemModel); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::EditRole)); + completer.setCompletionRole(Qt::ToolTipRole); + QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models + completer.setModel(&standardItemModel2); + QCOMPARE(completer.completionRole(), static_cast<int>(Qt::ToolTipRole)); +#endif // QT_NO_FILESYSTEMMODEL } void tst_QCompleter::csMatchingOnCsSortedModel_data() |