summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2021-06-02 16:29:44 +0200
committerAndreas Buhr <andreas.buhr@qt.io>2021-07-15 18:09:12 +0200
commit0c2125458a9fdddaf3385b257ba4350da872a1d1 (patch)
tree65c30aaf3436ec6e7571d43be24b2ec1c2c682eb /tests/auto/corelib
parent4cd2cca553ba2fdcd6cd59c2cd055fc8e6e83ae4 (diff)
Consistent handling of disabled items in QItemSelectionModel
In QItemSelectionModel, items which are disabled or marked as not selectable should not be considered as selected. But this was not handled consistently. The following methods considered only items which are enabled and marked selectable: selectedIndexes(), rowIntersectsSelection(), and columnIntersectsSelection(). The following methods considered only items which are marked selectable, but did not check whether they are enabled: selectedRows(), selectedColumns(), isRowSelected(), isColumnSelected(), isSelected(). Finally there is hasSelection(), which did not check for enabled nor for selectable. This patch introduces consistent behavior. All methods check both whether the items are enabled and whether they are selectable now. [ChangeLog][QtCore][QItemSelectionModel][Important Behavior Changes] All methods in QItemSelectionModel now consider only items which are marked as enabled and selectable as part of the selection. Fixes: QTBUG-93829 Pick-to: 6.2 Change-Id: I4725243ea6b0db4f289ce34ada22c7a9d3282713 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
index b7e13c8853..7c4dbaedbf 100644
--- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -2070,8 +2070,10 @@ void tst_QItemSelectionModel::unselectable()
selectionModel.select(QItemSelection(model.index(0, 0), model.index(9, 0)), QItemSelectionModel::Select);
QCOMPARE(selectionModel.selectedIndexes().count(), 10);
QCOMPARE(selectionModel.selectedRows().count(), 10);
+ QVERIFY(selectionModel.hasSelection());
for (int j = 0; j < 10; ++j)
model.item(j)->setFlags({ });
+ QVERIFY(!selectionModel.hasSelection());
QCOMPARE(selectionModel.selectedIndexes().count(), 0);
QCOMPARE(selectionModel.selectedRows().count(), 0);
}