diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-04-28 12:07:24 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-04-28 12:13:24 (GMT) |
commit | 49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f (patch) | |
tree | 4f6dfd2427c130338c41d2d1618ba745e838c979 /tests/auto | |
parent | 5d6a56fd14cb21d9955c49305993f7b7527a27c6 (diff) | |
download | Qt-49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f.zip Qt-49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f.tar.gz Qt-49708c6e6ac8e6641b1dfdf3ec2ebf347a8ca98f.tar.bz2 |
Fix regression in QSelectionModel::rowIntersectsSelection
and QSelectionModel::columnsIntersectsSelection
The documentation says "if one is selected" inside the row/column, so we
need to look over if we find one which is selected
Task-number: 252069
Reviewed-by: Marius Bugge Monsen
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 15b36b8..9bd1ce3 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -89,6 +89,7 @@ private slots: void merge_data(); void merge(); void task119433_isRowSelected(); + void task252069_rowIntersectsSelection(); private: QAbstractItemModel *model; @@ -2140,6 +2141,51 @@ void tst_QItemSelectionModel::task119433_isRowSelected() QVERIFY(sel.isRowSelected(0, QModelIndex())); } +void tst_QItemSelectionModel::task252069_rowIntersectsSelection() +{ + QStandardItemModel m; + for (int i=0; i<8; ++i) { + for (int j=0; j<8; ++j) { + QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + if ((i % 2 == 0 && j == 0) || + (j % 2 == 0 && i == 0) || + j == 5 || i == 5 ) { + item->setEnabled(false); + //item->setSelectable(false); + } + m.setItem(i, j, item); + } + } + + QItemSelectionModel selected(&m); + //nothing is selected + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(2, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); + selected.select(m.index(0, 5), QItemSelectionModel::Select | QItemSelectionModel::Columns); + QVERIFY(!selected.rowIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.rowIntersectsSelection(2, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.rowIntersectsSelection(5, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(0, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(2, QModelIndex())); + QVERIFY( selected.columnIntersectsSelection(3, QModelIndex())); + QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex())); +} QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" |