summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtreeview
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-09-01 14:39:30 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-09-01 14:41:31 (GMT)
commitefc616f2a1a83bd4ca50aea9d40a0df005ada063 (patch)
treec6dd80685a33c36156d2a5d50c4a4182b0b0309e /tests/auto/qtreeview
parent3dfde91fcbeaf304edd8d0d09e0732597055cd53 (diff)
downloadQt-efc616f2a1a83bd4ca50aea9d40a0df005ada063.zip
Qt-efc616f2a1a83bd4ca50aea9d40a0df005ada063.tar.gz
Qt-efc616f2a1a83bd4ca50aea9d40a0df005ada063.tar.bz2
QTreeView: exapnding nodes just after replacing the model wouldn't work
The problem is that deleting the previous model would triggera delayed reset. This reset could happen after the model has changed and nodes are expanded. We can now cancel a reset when reset is called from another place (like when we set a new model). Note: autotest included Task-number: 245654 Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto/qtreeview')
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index ef43c3a..6709807 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -233,6 +233,7 @@ private slots:
void task239271_addRowsWithFirstColumnHidden();
void task254234_proxySort();
void task248022_changeSelection();
+ void task245654_changeModelAndExpandAll();
};
class QtTestModel: public QAbstractItemModel
@@ -3463,6 +3464,35 @@ void tst_QTreeView::task248022_changeSelection()
QCOMPARE(view.selectionModel()->selectedIndexes().count(), list.count());
}
+void tst_QTreeView::task245654_changeModelAndExpandAll()
+{
+ QTreeView view;
+ QStandardItemModel *model = new QStandardItemModel;
+ QStandardItem *top = new QStandardItem("top");
+ QStandardItem *sub = new QStandardItem("sub");
+ top->appendRow(sub);
+ model->appendRow(top);
+ view.setModel(model);
+ view.expandAll();
+ QApplication::processEvents();
+ QVERIFY(view.isExpanded(top->index()));
+
+ //now let's try to delete the model
+ //then repopulate and expand again
+ delete model;
+ model = new QStandardItemModel;
+ top = new QStandardItem("top");
+ sub = new QStandardItem("sub");
+ top->appendRow(sub);
+ model->appendRow(top);
+ view.setModel(model);
+ view.expandAll();
+ QApplication::processEvents();
+ QVERIFY(view.isExpanded(top->index()));
+
+}
+
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"