summaryrefslogtreecommitdiffstats
path: root/tests/auto/qitemdelegate
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-08-23 23:10:16 +0200
committerPierre Rossi <pierre.rossi@nokia.com>2010-08-25 13:18:56 +0200
commit4284942fabd5ba8bb6299bff1f788ff566ff3fc2 (patch)
tree6468ac6580b51551eca2a74ac704da36370d8d7f /tests/auto/qitemdelegate
parenta30ad513df3af7e558d079df405a90e8601d2e74 (diff)
Don't toggle selected state when checking/unchecking an item
When selecting items with the mouse (and a keyboard modifier), clicking in the check rect of a checkable item shouldn't toggle the selected state but only check/uncheck it. Task-number: QTBUG-4435 Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qitemdelegate')
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 2a378fe3a8..97a9b82c2d 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -235,6 +235,7 @@ private slots:
void enterKey();
void task257859_finalizeEdit();
+ void QTBUG4435_keepSelectionOnCheck();
};
@@ -1168,6 +1169,31 @@ void tst_QItemDelegate::task257859_finalizeEdit()
QTRY_VERIFY(!editor);
}
+void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
+{
+ QStandardItemModel model(3, 1);
+ for (int i = 0; i < 3; ++i) {
+ QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
+ item->setCheckable(true);
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ model.setItem(i, item);
+ }
+ QTableView view;
+ view.setModel(&model);
+ view.setItemDelegate(new TestItemDelegate);
+ view.show();
+ view.selectAll();
+ QTest::qWaitForWindowShown(&view);
+ QStyleOptionViewItem option;
+ option.rect = view.visualRect(model.index(0, 0));
+ const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
+ QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
+ + QPoint(checkMargin, 0);
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
+ QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
+ QCOMPARE(model.item(0)->checkState(), Qt::Checked);
+}
+
// ### _not_ covered: