aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-08-10 14:13:52 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-08-11 14:58:35 +0200
commitb51ad14bc6a055de22b9c5f0083a3ca42795779b (patch)
tree957621b14753996b5eab5897167331f27bae1f2e /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
parente86a38f20f1b77ab2ee99de37e1f9724ce7cd14c (diff)
QQuickTableView: clear selection on tap directly in TableView
Before 6.4, it was only possible to make a selection in TableView by using a SelectionRectangle. But in 6.4, you can also make a selection directly in TableView by using the shift+arrow keys. To make sure that a selection is cleared either way on tap, move the implementation that clears the selection from SelectionRectangle to TableView. Pick-to: 6.4 Change-Id: Ic718763bf9b643cb3e3c04cc3b90c6ffcf9ca4b2 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 0455a16070..22dbfc08e1 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -199,6 +199,7 @@ private slots:
void testSelectableStartPosEndPosOutsideView();
void testSelectableScrollTowardsPos();
void setCurrentIndexFromSelectionModel();
+ void clearSelectionOnTap();
void moveCurrentIndexUsingArrowKeys();
void moveCurrentIndexUsingHomeAndEndKeys();
void moveCurrentIndexUsingPageUpDownKeys();
@@ -4443,6 +4444,29 @@ void tst_QQuickTableView::setCurrentIndexFromSelectionModel()
QVERIFY(tableView->itemAtCell(cellAtEnd)->property(kCurrent).toBool());
}
+void tst_QQuickTableView::clearSelectionOnTap()
+{
+ LOAD_TABLEVIEW("tableviewwithselected2.qml");
+
+ TestModel model(40, 40);
+ tableView->setModel(QVariant::fromValue(&model));
+
+ WAIT_UNTIL_POLISHED;
+
+ // Select root item
+ const auto index = tableView->selectionModel()->model()->index(0, 0);
+ tableView->selectionModel()->select(index, QItemSelectionModel::Select);
+ QCOMPARE(tableView->selectionModel()->selectedIndexes().count(), 1);
+
+ // Click on a cell. This should remove the selection
+ const auto item = tableView->itemAtCell(0, 0);
+ QVERIFY(item);
+ QPoint localPos = QPoint(item->width() / 2, item->height() / 2);
+ QPoint pos = item->window()->contentItem()->mapFromItem(item, localPos).toPoint();
+ QTest::mouseClick(item->window(), Qt::LeftButton, Qt::NoModifier, pos);
+ QCOMPARE(tableView->selectionModel()->selectedIndexes().count(), 0);
+}
+
void tst_QQuickTableView::moveCurrentIndexUsingArrowKeys()
{
LOAD_TABLEVIEW("tableviewwithselected1.qml");