diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-02-26 16:47:42 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-03-01 05:21:36 +0000 |
commit | b1d95c6702160afc9bbb0dee39462bc1a547cb8b (patch) | |
tree | a49dbea287068da303054c588fa94c9f81a5d5ad /tests/auto/widgets/itemviews | |
parent | 550ee1d7529af7440cf3e3444526249f3de3e4ab (diff) | |
download | qtbase-b1d95c6702160afc9bbb0dee39462bc1a547cb8b.tar.gz |
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: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r-- | tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 29 |
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 97290d0aa9..fc984cef6e 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -754,22 +754,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); } @@ -3043,6 +3027,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() |