From 27380de043105379002075543fffdd67718138ca Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 23 Mar 2010 10:35:57 +0100 Subject: Adding the autotest for the task Task-number: QTBUG-2804 --- .../tst_qitemselectionmodel.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 6ef4305..3b2a716 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -93,6 +93,7 @@ private slots: void task232634_childrenDeselectionSignal(); void task260134_layoutChangedWithAllSelected(); void QTBUG5671_layoutChangedWithAllSelected(); + void QTBUG2804_layoutChangedTreeSelection(); private: QAbstractItemModel *model; @@ -2327,5 +2328,31 @@ void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected() QVERIFY(selection.isSelected(index)); } +void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection() +{ + QStandardItemModel model; + QStandardItem top1("Child1"), top2("Child2"), top3("Child3"); + QStandardItem sub11("Alpha"), sub12("Beta"), sub13("Gamma"), sub14("Delta"), + sub21("Alpha"), sub22("Beta"), sub23("Gamma"), sub24("Delta"); + top1.appendColumn(QList() << &sub11 << &sub12 << &sub13 << &sub14); + top2.appendColumn(QList() << &sub21 << &sub22 << &sub23 << &sub24); + model.appendColumn(QList() << &top1 << &top2 << &top3); + + QItemSelectionModel selModel(&model); + + selModel.select(sub11.index(), QItemSelectionModel::Select); + selModel.select(sub12.index(), QItemSelectionModel::Select); + selModel.select(sub21.index(), QItemSelectionModel::Select); + selModel.select(sub23.index(), QItemSelectionModel::Select); + + QModelIndexList list = selModel.selectedIndexes(); + QCOMPARE(list.count(), 4); + + model.sort(0); //this will provoke a relayout + + QCOMPARE(selModel.selectedIndexes().count(), 4); +} + + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12