diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-09-08 10:59:44 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-09-08 11:01:28 (GMT) |
commit | 9d9b7f53750dce2da88d7d11d312b4b36250b5c5 (patch) | |
tree | 2dfec33fb3da2c19f0ac33d81f67ec36cf8617a5 /tests/auto | |
parent | 9a90fcca3e9a9a49cee228054017ff7d15645082 (diff) | |
download | Qt-9d9b7f53750dce2da88d7d11d312b4b36250b5c5.zip Qt-9d9b7f53750dce2da88d7d11d312b4b36250b5c5.tar.gz Qt-9d9b7f53750dce2da88d7d11d312b4b36250b5c5.tar.bz2 |
Fixes a regression in QListView in 4.6 regarding the selection
In icon mode, if you click on the viewport (with extended selection),
the selection should be cleared when you release the mouse button.
Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2be1a03..2831747 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -113,6 +113,7 @@ private slots: void task254449_draggingItemToNegativeCoordinates(); void keyboardSearch(); void shiftSelectionWithNonUniformItemSizes(); + void clickOnViewportClearsSelection(); }; // Testing get/set functions @@ -1733,5 +1734,34 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() } } +void tst_QListView::clickOnViewportClearsSelection() +{ + QStringList items; + items << "Text1"; + QStringListModel model(items); + QListView view; + view.setModel(&model); + view.setSelectionMode(QListView::ExtendedSelection); + + view.selectAll(); + QModelIndex index = model.index(0); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + //we try to click outside of the index + const QPoint point = view.visualRect(index).bottomRight() + QPoint(10,10); + + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, point); + //at this point, the selection shouldn't have changed + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point); + //now the selection should be cleared + QVERIFY(!view.selectionModel()->hasSelection()); + +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |