summaryrefslogtreecommitdiffstats
path: root/tests/auto/qitemselectionmodel
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-07 15:14:31 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-07 15:14:31 (GMT)
commitd13418effc5f00474541ae513a30c9a42c2a1cb3 (patch)
tree9ce95e34eaf57b2936cc77c7004988493433c093 /tests/auto/qitemselectionmodel
parent132a319dc782ef1feebe6582fb6f05dc91df74bb (diff)
downloadQt-d13418effc5f00474541ae513a30c9a42c2a1cb3.zip
Qt-d13418effc5f00474541ae513a30c9a42c2a1cb3.tar.gz
Qt-d13418effc5f00474541ae513a30c9a42c2a1cb3.tar.bz2
QItemSelectionModel did not send selectionChanged signal when deleting an item
in a tree-like model with one of its grand-children being selected. Added recursive deselection for the model. Task-number: 232634 Reviewed-by: thierry
Diffstat (limited to 'tests/auto/qitemselectionmodel')
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 0541b46..05e23f1 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -90,6 +90,7 @@ private slots:
void merge();
void task119433_isRowSelected();
void task252069_rowIntersectsSelection();
+ void task232634_childrenDeselectionSignal();
private:
QAbstractItemModel *model;
@@ -2187,5 +2188,28 @@ void tst_QItemSelectionModel::task252069_rowIntersectsSelection()
QVERIFY(!selected.columnIntersectsSelection(5, QModelIndex()));
}
+void tst_QItemSelectionModel::task232634_childrenDeselectionSignal()
+{
+ QStandardItemModel model;
+
+ QStandardItem *parentItem = model.invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
+ parentItem->appendRow(item);
+ parentItem = item;
+ }
+
+ QModelIndex root = model.index(0,0);
+ QModelIndex par = root.child(0,0);
+ QModelIndex sel = par.child(0,0);
+
+ QItemSelectionModel selectionModel(&model);
+ selectionModel.select(sel, QItemSelectionModel::SelectCurrent);
+
+ QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(const QItemSelection& , const QItemSelection&)));
+ model.removeRows(0, 1, root);
+ QVERIFY(deselectSpy.count() == 1);
+}
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"