1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef KITEMLISTVIEWANIMATION_H
21 #define KITEMLISTVIEWANIMATION_H
23 #include <libdolphin_export.h>
30 class QGraphicsWidget
;
32 class QPropertyAnimation
;
35 * @brief Internal helper class for KItemListView to animate the items.
37 * Supports item animations for moving, creating, deleting and resizing
38 * an item. Several applications can be applied to one item in parallel.
40 class LIBDOLPHINPRIVATE_EXPORT KItemListViewAnimation
: public QObject
52 KItemListViewAnimation(QObject
* parent
= 0);
53 virtual ~KItemListViewAnimation();
55 void setScrollOrientation(Qt::Orientation orientation
);
56 Qt::Orientation
scrollOrientation() const;
58 void setScrollOffset(qreal scrollOffset
);
59 qreal
scrollOffset() const;
62 * Starts the animation of the type \a type for the widget \a widget. If an animation
63 * of the type is already running, this animation will be stopped before starting
66 void start(QGraphicsWidget
* widget
, AnimationType type
, const QVariant
& endValue
= QVariant());
69 * Stops the animation of the type \a type for the widget \a widget.
71 void stop(QGraphicsWidget
* widget
, AnimationType type
);
74 * Stops all animations that have been applied to the widget \a widget.
76 void stop(QGraphicsWidget
* widget
);
79 * @return True if the animation of the type \a type has been started
80 * for the widget \a widget..
82 bool isStarted(QGraphicsWidget
*widget
, AnimationType type
) const;
85 * @return True if any animation has been started for the widget.
87 bool isStarted(QGraphicsWidget
* widget
) const;
90 void finished(QGraphicsWidget
* widget
, KItemListViewAnimation::AnimationType type
);
96 enum { AnimationTypeCount
= 4 };
98 int m_animationDuration
;
99 Qt::Orientation m_scrollOrientation
;
100 qreal m_scrollOffset
;
101 QHash
<QGraphicsWidget
*, QPropertyAnimation
*> m_animation
[AnimationTypeCount
];