summaryrefslogtreecommitdiffstats
path: root/tests/auto/qitemselectionmodel
diff options
context:
space:
mode:
authorStephen Kelly <stephen@kdab.com>2010-08-19 16:41:40 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2010-08-19 16:41:40 (GMT)
commit6e24bef57683b26f7cc1c4cddacace413d181d00 (patch)
tree00edc3ad4c8fe64f40ab09550e039e52c05b5d09 /tests/auto/qitemselectionmodel
parent9b4c6ab8e27873c133f16ea655d7220b1ba348cf (diff)
downloadQt-6e24bef57683b26f7cc1c4cddacace413d181d00.zip
Qt-6e24bef57683b26f7cc1c4cddacace413d181d00.tar.gz
Qt-6e24bef57683b26f7cc1c4cddacace413d181d00.tar.bz2
Make the QItemSelectionRange and QItemSelectionModel ensure that the model is correct.
Merge-request: 720 Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Diffstat (limited to 'tests/auto/qitemselectionmodel')
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 46bd4a2..69b1390 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -98,6 +98,8 @@ private slots:
void rangeOperatorLessThan_data();
void rangeOperatorLessThan();
+ void testDifferentModels();
+
private:
QAbstractItemModel *model;
QItemSelectionModel *selection;
@@ -2561,5 +2563,31 @@ void tst_QItemSelectionModel::rangeOperatorLessThan()
QVERIFY(r4 < r2);
}
+void tst_QItemSelectionModel::testDifferentModels()
+{
+ QStandardItemModel model1;
+ QStandardItemModel model2;
+ QStandardItem top11("Child1"), top12("Child2"), top13("Child3");
+ QStandardItem top21("Child1"), top22("Child2"), top23("Child3");
+
+ model1.appendColumn(QList<QStandardItem*>() << &top11 << &top12 << &top13);
+ model2.appendColumn(QList<QStandardItem*>() << &top21 << &top22 << &top23);
+
+
+ QModelIndex topIndex1 = model1.index(0, 0);
+ QModelIndex bottomIndex1 = model1.index(2, 0);
+ QModelIndex topIndex2 = model2.index(0, 0);
+
+ QItemSelectionRange range(topIndex1, bottomIndex1);
+
+ QVERIFY(range.intersects(QItemSelectionRange(topIndex1, topIndex1)));
+ QVERIFY(!range.intersects(QItemSelectionRange(topIndex2, topIndex2)));
+
+ QItemSelection newSelection;
+ QItemSelection::split(range, QItemSelectionRange(topIndex2, topIndex2), &newSelection);
+
+ QVERIFY(newSelection.isEmpty());
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"