aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-11-09 10:41:12 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2022-11-16 00:24:23 +0100
commit3af953871300f3eba3f6647e96a4e98532c4293a (patch)
tree31c93a9e3010014aee49d41d3547f9427ab2a2fb /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
parent7fa4a53ebba1d10f249d017551e618b0406a3b57 (diff)
QQuickTableView: don't change index if tapping on the resize area
The current implementation would change the current index when a single tap was done on the resize area between the cells. But doing that was not ideal if the tap turned out to be a double tap instead, since a double tap should only reset the column size. The current solution would solve this by using exclusive signals on the tap handler. But despite of that, it would still look wrong that a tap on the resize area, while the cursor has a resize appearance, changed the index. Using exclusive signals also comes with a small signal delay. So, all in all, it's simply better to change the logic so that the resize area is reserved for resizing only. And then, to change the current index, the tap needs to happen outside the resize area. Change-Id: I1e7cb8d1031d1b86c14d777c322f1717fa5eb171 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 4914af8a3c..f04816b167 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -6270,23 +6270,33 @@ void tst_QQuickTableView::dragFromCellCenter()
void tst_QQuickTableView::tapOnResizeArea_data()
{
- QTest::addColumn<bool>("pointerNavigationEnabled");
- QTest::newRow("pointer naviagation enabled") << true;
- QTest::newRow("pointer naviagation disabled") << false;
+ QTest::addColumn<bool>("resizableRows");
+ QTest::addColumn<bool>("resizableColumns");
+ QTest::addColumn<bool>("interactive");
+
+ for (bool interactive : {true, false}) {
+ QTest::newRow("resize disabled") << false << false << interactive;
+ QTest::newRow("resizableRows") << true << false << interactive;
+ QTest::newRow("resizableColumns") << false << true << interactive;
+ QTest::newRow("resizableRows && resizableColumns") << true << true << interactive;
+ }
}
void tst_QQuickTableView::tapOnResizeArea()
{
- // Check that the user can tap close to the edge of a cell, on the resize area, and
- // as such, change the current index (unless pointer navigation is disabled).
- QFETCH(bool, pointerNavigationEnabled);
+ // Check that if a tap or a press happens on the resize area between the
+ // cells, we only change the current index if the resizing is disabled.
+ QFETCH(bool, resizableRows);
+ QFETCH(bool, resizableColumns);
+ QFETCH(bool, interactive);
LOAD_TABLEVIEW("tableviewwithselected2.qml");
auto model = TestModel(3, 3);
tableView->setModel(QVariant::fromValue(&model));
- tableView->setResizableColumns(true);
- tableView->setResizableRows(true);
- tableView->setPointerNavigationEnabled(pointerNavigationEnabled);
+ tableView->setResizableRows(resizableRows);
+ tableView->setResizableColumns(resizableColumns);
+ tableView->setInteractive(interactive);
+ tableView->setPointerNavigationEnabled(true);
WAIT_UNTIL_POLISHED;
@@ -6297,13 +6307,16 @@ void tst_QQuickTableView::tapOnResizeArea()
const QPoint localPos = QPoint(item->width() - 1, item->height() - 1);
const QPoint tapPos = window->contentItem()->mapFromItem(item, localPos).toPoint();
+ // Start by moving the mouse out of the way
+ QTest::mouseMove(window, tapPos + QPoint(200, 200));
+ // Then do a tap on the resize area
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, tapPos);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, tapPos);
- if (pointerNavigationEnabled)
- QCOMPARE(tableView->selectionModel()->currentIndex(), model.index(1, 1));
- else
+ if (resizableRows || resizableColumns)
QVERIFY(!tableView->selectionModel()->currentIndex().isValid());
+ else
+ QCOMPARE(tableView->selectionModel()->currentIndex(), model.index(1, 1));
}
QTEST_MAIN(tst_QQuickTableView)