summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qitemdelegate
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-05-28 13:03:34 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-07 20:23:17 +0200
commitdc5e8aa81c7083659e2ec3090489f34072ebc383 (patch)
treeb064e7dc6a443bb4425230f15875741550d9ceb0 /tests/auto/widgets/itemviews/qitemdelegate
parentad554707dc1e564fa0ac0f164ed093ddc80f14b0 (diff)
QAbstractItemView: don't toggle extended selection on Ctrl+Press
In ExtendedSelection mode, a Ctrl+Press might be both the start of a selection toggle, or the start of a Ctrl+Drag operation. If we already toggle on the press, then it's impossible to drag the existing selection while the Control key is pressed. Ignore Ctrl+Press events and let the corresponding release event toggle the selection. Adjust the relevant test cases accordingly. The QItemDelegate test case used a click+control event incorrectly, such an event doesn't change the clicked state and should not be eaten, and now it does change the selection, so fix the test. Task-number: QTBUG-59888 Change-Id: Ia76126e31c28bc97d3e93e54965bdb1d0b8ac6a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews/qitemdelegate')
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 25212373a4..8d68ca7ac9 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1394,6 +1394,7 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
}
QTableView view;
view.setModel(&model);
+ view.setSelectionMode(QAbstractItemView::MultiSelection);
view.setItemDelegate(new TestItemDelegate(&view));
view.show();
view.selectAll();
@@ -1404,11 +1405,16 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator;
option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt());
const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
- QPoint pos = qApp->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, 0).center()
- + QPoint(checkMargin, 0);
- QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
- QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
+ QRect checkRect = qApp->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, 0);
+ checkRect.translate(checkMargin, 0);
+ // click into the check mark checks, but doesn't change selection
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center());
QCOMPARE(model.item(0)->checkState(), Qt::Checked);
+ QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
+ // click outside the check mark doesn't check, and changes selection
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier,
+ checkRect.center() + QPoint(checkRect.width(), 0));
+ QTRY_VERIFY(!view.selectionModel()->isColumnSelected(0, QModelIndex()));
}
void tst_QItemDelegate::comboBox()