summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-11-23 15:24:48 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-29 09:28:43 +0100
commitd315e012184a2b71b7b5e41869d166c05093d13d (patch)
treeeef06bdd093861b8e0e394021ba398a0cf83294d /tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
parentd78bd439dcb290e4318734693d418937b0bf8129 (diff)
Add the Qt::ItemNeverHasChildren flag and use it in QTreeView.
It can be used to determine whether expand() should really expand. Change-Id: If79d8c295a4ca1356e60051682b227524a065126 Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 0f69e951bf..a1de5f190c 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -177,6 +177,7 @@ private slots:
void emptyModel();
void removeRows();
void removeCols();
+ void limitedExpand();
void expandAndCollapse_data();
void expandAndCollapse();
void expandAndCollapseAll();
@@ -1414,6 +1415,45 @@ void tst_QTreeView::removeCols()
QCOMPARE(view.header()->count(), model.cols);
}
+void tst_QTreeView::limitedExpand()
+{
+ {
+ QStandardItemModel model;
+ QStandardItem *parentItem = model.invisibleRootItem();
+ parentItem->appendRow(new QStandardItem);
+ parentItem->appendRow(new QStandardItem);
+ parentItem->appendRow(new QStandardItem);
+
+ QStandardItem *firstItem = model.item(0, 0);
+ firstItem->setFlags(firstItem->flags() | Qt::ItemNeverHasChildren);
+
+ QTreeView view;
+ view.setModel(&model);
+
+ QSignalSpy spy(&view, SIGNAL(expanded(QModelIndex)));
+ QVERIFY(spy.isValid());
+
+ view.expand(model.index(0, 0));
+ QCOMPARE(spy.count(), 0);
+
+ view.expand(model.index(1, 0));
+ QCOMPARE(spy.count(), 1);
+ }
+ {
+ QStringListModel model(QStringList() << "one" << "two");
+ QTreeView view;
+ view.setModel(&model);
+
+ QSignalSpy spy(&view, SIGNAL(expanded(QModelIndex)));
+ QVERIFY(spy.isValid());
+
+ view.expand(model.index(0, 0));
+ QCOMPARE(spy.count(), 0);
+ view.expandAll();
+ QCOMPARE(spy.count(), 0);
+ }
+}
+
void tst_QTreeView::expandAndCollapse_data()
{
QTest::addColumn<bool>("animationEnabled");