diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-09 10:10:18 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-09 11:46:53 (GMT) |
commit | c5371bd1f3df4467ca17350ec7c3e3635d16e393 (patch) | |
tree | 11e7862bce0a03a718e166002e6af977ea1d3271 /src/gui/itemviews/qtreeview_p.h | |
parent | 916b5c69e1ed5667e4fe97a21e7e15abfd60ec3d (diff) | |
download | Qt-c5371bd1f3df4467ca17350ec7c3e3635d16e393.zip Qt-c5371bd1f3df4467ca17350ec7c3e3635d16e393.tar.gz Qt-c5371bd1f3df4467ca17350ec7c3e3635d16e393.tar.bz2 |
QTreeView: use QVariantAnimation over QTimeLine
Diffstat (limited to 'src/gui/itemviews/qtreeview_p.h')
-rw-r--r-- | src/gui/itemviews/qtreeview_p.h | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index 6a1dfe5..77e57d6 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -54,6 +54,7 @@ // #include "private/qabstractitemview_p.h" +#include <QtCore/qvariantanimation.h> #ifndef QT_NO_TREEVIEW @@ -81,42 +82,48 @@ public: uniformRowHeights(false), rootDecoration(true), itemsExpandable(true), sortingEnabled(false), expandsOnDoubleClick(true), - allColumnsShowFocus(false), + allColumnsShowFocus(false), current(0), animationsEnabled(false), columnResizeTimerID(0), autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false) {} ~QTreeViewPrivate() {} void initialize(); - struct AnimatedOperation +#ifndef QT_NO_ANIMATION + struct AnimatedOperation : public QVariantAnimation { - enum Type { Expand, Collapse }; int item; - int top; - int duration; - Type type; QPixmap before; QPixmap after; - }; - - void expand(int item, bool emitSignal); - void collapse(int item, bool emitSignal); - - void prepareAnimatedOperation(int item, AnimatedOperation::Type type); + QTreeView *view; + AnimatedOperation() : item(0) { setEasingCurve(QEasingCurve::InOutQuad); } + int top() const { return startValue().toInt(); } + QRect rect() const { QRect rect = view->viewport()->rect(); rect.moveTop(top()); return rect; } + void updateCurrentValue(const QVariant &) { view->viewport()->update(rect()); } + void updateState(State, State state) + { + if (state == Stopped) { + before = after = QPixmap(); + view->setState(QAbstractItemView::NoState); + view->updateGeometries(); + view->viewport()->update(); + } + } + } animatedOperation; + void prepareAnimatedOperation(int item, QVariantAnimation::Direction d); void beginAnimatedOperation(); - void _q_endAnimatedOperation(); void drawAnimatedOperation(QPainter *painter) const; QPixmap renderTreeToPixmapForAnimation(const QRect &rect) const; +#endif //QT_NO_ANIMATION + + void expand(int item, bool emitSignal); + void collapse(int item, bool emitSignal); - inline QRect animationRect() const - { return QRect(0, animatedOperation.top, viewport->width(), - viewport->height() - animatedOperation.top); } void _q_currentChanged(const QModelIndex&, const QModelIndex&); void _q_columnsAboutToBeRemoved(const QModelIndex &, int, int); void _q_columnsRemoved(const QModelIndex &, int, int); void _q_modelAboutToBeReset(); - void _q_animate(); void _q_sortIndicatorChanged(int column, Qt::SortOrder order); void _q_modelDestroyed(); @@ -177,8 +184,6 @@ public: // used when expanding and collapsing items QSet<QPersistentModelIndex> expandedIndexes; - QStack<bool> expandParent; - AnimatedOperation animatedOperation; bool animationsEnabled; inline bool storeExpanded(const QPersistentModelIndex &idx) { |