2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef KITEMLISTVIEWANIMATION_H
8 #define KITEMLISTVIEWANIMATION_H
10 #include "dolphin_export.h"
17 class QGraphicsWidget
;
18 class QPropertyAnimation
;
21 * @brief Internal helper class for KItemListView to animate the items.
23 * Supports item animations for moving, creating, deleting and resizing
24 * an item. Several applications can be applied to one item in parallel.
26 class DOLPHIN_EXPORT KItemListViewAnimation
: public QObject
31 enum AnimationType
{ MovingAnimation
, CreateAnimation
, DeleteAnimation
, ResizeAnimation
, IconResizeAnimation
, AnimationTypeCount
};
33 explicit KItemListViewAnimation(QObject
*parent
= nullptr);
34 ~KItemListViewAnimation() override
;
36 void setScrollOrientation(Qt::Orientation orientation
);
37 Qt::Orientation
scrollOrientation() const;
39 void setScrollOffset(qreal scrollOffset
);
40 qreal
scrollOffset() const;
43 * Starts the animation of the type \a type for the widget \a widget. If an animation
44 * of the type is already running, this animation will be stopped before starting
47 void start(QGraphicsWidget
*widget
, AnimationType type
, const QVariant
&endValue
= QVariant());
50 * Stops the animation of the type \a type for the widget \a widget.
52 void stop(QGraphicsWidget
*widget
, AnimationType type
);
55 * Stops all animations that have been applied to the widget \a widget.
57 void stop(QGraphicsWidget
*widget
);
60 * @return True if the animation of the type \a type has been started
61 * for the widget \a widget..
63 bool isStarted(QGraphicsWidget
*widget
, AnimationType type
) const;
66 * @return True if any animation has been started for the widget.
68 bool isStarted(QGraphicsWidget
*widget
) const;
71 void finished(QGraphicsWidget
*widget
, KItemListViewAnimation::AnimationType type
);
77 Qt::Orientation m_scrollOrientation
;
79 QHash
<QGraphicsWidget
*, QPropertyAnimation
*> m_animation
[AnimationTypeCount
];