summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorThierry Bastian <thierryb@filewave.com>2012-08-29 11:10:23 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-08-31 12:47:18 (GMT)
commita5a1121315d55f5af9d1ff4c926dd0d18e39f9df (patch)
tree29f7bde6d1370b91306e4bdd791976d14089e70e /src/gui
parentf9040233ef609f6aad3e2eed7dd07788bf7b5f03 (diff)
downloadQt-a5a1121315d55f5af9d1ff4c926dd0d18e39f9df.zip
Qt-a5a1121315d55f5af9d1ff4c926dd0d18e39f9df.tar.gz
Qt-a5a1121315d55f5af9d1ff4c926dd0d18e39f9df.tar.bz2
Fixed the QTreeView expansion/collpasing when animated
If you had a QTreeView with expandable items, if you tried to expand and while the animation was still running you'd try to collpase the node, the display would be completely broken: the items below that items would not be visible any more except for a fraction of a second when expanding or collapsing it again. The problem is in the fact that when starting an animation the QTreeView stores the state before animating. And it does that even if an animation is already running. So the stateBeforeAnimation becomes AnimatingState and when the animation finishes, AnimatingState is the state that is restored breaking the painting. Unit test is included. qtbase-sha1: 1e97dbaf6ca807397e3ec77a3611763769499d17 Change-Id: I62e16101b70153f78022f6195fd9de6db0cd4878 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/itemviews/qtreeview.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index bc9d54c..40234e0 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2884,7 +2884,9 @@ void QTreeViewPrivate::expand(int item, bool emitSignal)
if (emitSignal && animationsEnabled)
prepareAnimatedOperation(item, QVariantAnimation::Forward);
#endif //QT_NO_ANIMATION
- stateBeforeAnimation = state;
+ //if already animating, stateBeforeAnimation is set to the correct value
+ if (state != QAbstractItemView::AnimatingState)
+ stateBeforeAnimation = state;
q->setState(QAbstractItemView::ExpandingState);
const QModelIndex index = viewItems.at(item).index;
storeExpanded(index);
@@ -2975,7 +2977,9 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal)
prepareAnimatedOperation(item, QVariantAnimation::Backward);
#endif //QT_NO_ANIMATION
- stateBeforeAnimation = state;
+ //if already animating, stateBeforeAnimation is set to the correct value
+ if (state != QAbstractItemView::AnimatingState)
+ stateBeforeAnimation = state;
q->setState(QAbstractItemView::CollapsingState);
expandedIndexes.erase(it);
viewItems[item].expanded = false;