summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-10-20 13:52:38 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-10-20 13:52:38 (GMT)
commit77f055ab9474ec4d3311884c293af7ee4a2a7cb3 (patch)
tree9b2b239608c01da1715f6a9e85668eda83c519f7
parente64b5fa1312f42fa6377e28c11f8aa3a3413280f (diff)
downloadQt-77f055ab9474ec4d3311884c293af7ee4a2a7cb3.zip
Qt-77f055ab9474ec4d3311884c293af7ee4a2a7cb3.tar.gz
Qt-77f055ab9474ec4d3311884c293af7ee4a2a7cb3.tar.bz2
Fixed QTreeView trying to animate when parent item has no child
We now check that the item has children before animating. Reviewed-by: Alexis
-rw-r--r--src/gui/itemviews/qtreeview.cpp6
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp14
2 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 210534e..d597f5c 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2908,15 +2908,15 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
layout(item);
q->setState(oldState);
+ if (model->canFetchMore(index))
+ model->fetchMore(index);
if (emitSignal) {
emit q->expanded(index);
#ifndef QT_NO_ANIMATION
- if (animationsEnabled)
+ if (animationsEnabled && model->hasChildren(index))
beginAnimatedOperation();
#endif //QT_NO_ANIMATION
}
- if (model->canFetchMore(index))
- model->fetchMore(index);
}
void QTreeViewPrivate::collapse(int item, bool emitSignal)
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 91b2cc5..da58725 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -172,6 +172,7 @@ private slots:
void expandAndCollapse_data();
void expandAndCollapse();
void expandAndCollapseAll();
+ void expandWithNoChildren();
void keyboardNavigation();
void headerSections();
void moveCursor_data();
@@ -1548,6 +1549,19 @@ void tst_QTreeView::expandAndCollapseAll()
// QCOMPARE(collapsedSpy.count(), count);
}
+void tst_QTreeView::expandWithNoChildren()
+{
+ QTreeView tree;
+ QStandardItemModel model(1,1);
+ tree.setModel(&model);
+ tree.setAnimated(true);
+ tree.doItemsLayout();
+ //this test should not output warnings
+ tree.expand(model.index(0,0));
+}
+
+
+
void tst_QTreeView::keyboardNavigation()
{
const int rows = 10;