From 4910f416c2c0d1ec4a11408647bc6c96c719ce18 Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 15 Jan 2015 14:12:34 +0100 Subject: Itemviews: add ItemIsUserTristate flag ItemIsTristate is now again purely for enabling the automatic management of the check state of QTreeWidgetItems, while ItemIsUserTristate is separate from that and lets the user select the three states manually. This restores the original behavior of ItemIsTristate for QTreeWidgetItems, which got broken by letting the user cycle through the states too. [ChangeLog][QtWidgets][QTreeWidget] Restored Qt 5.1 behavior of QTreeWidgetItems with ItemIsTristate to enable automatic management of the check state. User-editable tristate checkboxes are now enabled by setting the new flag ItemIsUserTristate. Task-number: QTBUG-40060 Change-Id: I341f5e983804d3b4f27982520bb6647f3014cccc Reviewed-by: Oswald Buddenhagen Reviewed-by: Jarek Kobus --- .../itemviews/qitemdelegate/tst_qitemdelegate.cpp | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests/auto/widgets/itemviews/qitemdelegate') diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index 0ecb1d1af4..0d1f11c1b5 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -1159,7 +1159,7 @@ void tst_QItemDelegate::editorEvent_data() << (int)(QEvent::MouseButtonRelease) << (int)(Qt::LeftButton) << true - << (int)(Qt::PartiallyChecked); + << (int)(Qt::Checked); QTest::newRow("partially checked, tristate, release") << (int)(Qt::PartiallyChecked) @@ -1178,6 +1178,33 @@ void tst_QItemDelegate::editorEvent_data() << (int)(Qt::LeftButton) << true << (int)(Qt::Unchecked); + + QTest::newRow("unchecked, user-tristate, release") + << (int)(Qt::Unchecked) + << (int)(defaultFlags | Qt::ItemIsUserTristate) + << true + << (int)(QEvent::MouseButtonRelease) + << (int)(Qt::LeftButton) + << true + << (int)(Qt::PartiallyChecked); + + QTest::newRow("partially checked, user-tristate, release") + << (int)(Qt::PartiallyChecked) + << (int)(defaultFlags | Qt::ItemIsUserTristate) + << true + << (int)(QEvent::MouseButtonRelease) + << (int)(Qt::LeftButton) + << true + << (int)(Qt::Checked); + + QTest::newRow("checked, user-tristate, release") + << (int)(Qt::Checked) + << (int)(defaultFlags | Qt::ItemIsUserTristate) + << true + << (int)(QEvent::MouseButtonRelease) + << (int)(Qt::LeftButton) + << true + << (int)(Qt::Unchecked); } void tst_QItemDelegate::editorEvent() -- cgit v1.2.3