summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <frank78ac@googlemail.com>2015-03-10 23:05:22 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-03-22 14:38:07 +0000
commitf1e90768095be37419ba4bf3c69ec5c860bdbcb6 (patch)
treeac652951734f49112a6dcc8337b814af14cba03c /tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
parente6b97fd2c793ae702cf2102e43ce9efb4d27983a (diff)
Fix problems with extended selection after changing the model contents
Storing the position of the first selected item in the view can lead to wrong extended selections if the contents of the model change. Future Shift-clicks will always use the previous position of the first selected item, which may not be correct any more, to calculate the current selection. To fix this problem, a QPersistentModelIndex is used to keep track of the first selected item. A new unit test is added. Moreover, one function of the QTableView unit test is changed such that it shows the view prior to performing the test. Without this change, this test may fail. That the test, which simulates mouse presses without showing the view, worked at all seems to be a coincidence, as pointed out in QTBUG-18009. Task-number: QTBUG-18009 Change-Id: I0d844fbd1a994c279a7c8ee5d9b5b9fccecd25bf Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index a11d423896..75f77f8107 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -4288,6 +4288,9 @@ void tst_QTableView::taskQTBUG_4516_clickOnRichTextLabel()
QLabel label("rich text");
label.setTextFormat(Qt::RichText);
view.setIndexWidget(model.index(1,1), &label);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
view.setCurrentIndex(model.index(0,0));
QCOMPARE(view.currentIndex(), model.index(0,0));