summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-26 16:47:42 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-28 18:21:15 +0000
commit09bf5a439e62dbd9b634b912ba6895862e17105b (patch)
treebf7149d068e412cdccd1d569c70dde716bc9f904 /tests
parentdfa04903c6fc9d228dd52a7ec04d42a293cc2c6b (diff)
QAbtractItemView: deselect before click opens editor
A click on the selected item should deselect all other items before editing starts. Remove the part of the test case that assumes that we can have multiple items selected in ExtendedSelection mode, and click on an item to start editing while maintaining selection. That can never happen. Fixes: QTBUG-111131 Change-Id: I0312eed4614502cfb77eca26d3f7615427493d7d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 3f2d02e2f4436ace5f0fbbf432878a963f5ee969) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index e765427e3f..c047b823aa 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -777,22 +777,6 @@ void tst_QAbstractItemView::pressClosesReleaseDoesntOpenEditor()
QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // should not reopen editor
QTest::qWait(QApplication::doubleClickInterval() * 2);
QCOMPARE(view.state(), QAbstractItemView::NoState);
-
- // with multiple items selected, clicking from the currently edited item into another
- // selected item closes the current and reopens a new editor
- view.setSelectionMode(QAbstractItemView::ExtendedSelection);
- const QRect child2Rect = view.visualRect(model.indexFromItem(parent->child(1)));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, child2Rect.center()); // select
- QVERIFY(view.selectionModel()->selectedIndexes().contains(model.indexFromItem(parent->child(0))));
- QVERIFY(view.selectionModel()->selectedIndexes().contains(model.indexFromItem(parent->child(1))));
- QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, child2Rect.center()); // edit
- QTRY_COMPARE(view.state(), QAbstractItemView::EditingState);
- QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // editor closes
- QCOMPARE(view.state(), QAbstractItemView::NoState);
- QTest::qWait(10); // process some events, let the internal timer time out
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, inChildOutsideEditor); // should open editor
- QTest::qWait(QApplication::doubleClickInterval() * 2);
- QCOMPARE(view.state(), QAbstractItemView::EditingState);
}
@@ -3063,6 +3047,19 @@ void tst_QAbstractItemView::mouseSelection_data()
<< QList{SelectionEvent(SelectionEvent::Click, 3),
SelectionEvent(SelectionEvent::Click, Qt::ControlModifier, 3)}
<< QList<int>{};
+ // Extended: when drag is enabled, click on selected without Ctrl clears before editing
+ QTest::addRow("Extended:Range,Click,editable") << QAbstractItemView::ExtendedSelection << false
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 1),
+ SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 3),
+ SelectionEvent(SelectionEvent::Click, 2)}
+ << QList<int>{2};
+ QTest::addRow("Extended:Range,Click,dragable,editable") << QAbstractItemView::ExtendedSelection << true
+ << QAbstractItemView::SelectedClicked
+ << QList{SelectionEvent(SelectionEvent::Click, 1),
+ SelectionEvent(SelectionEvent::Click, Qt::ShiftModifier, 3),
+ SelectionEvent(SelectionEvent::Click, 2)}
+ << QList<int>{2};
}
void tst_QAbstractItemView::mouseSelection()