File indexing completed on 2024-05-12 05:47:31
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KITEMLISTVIEWANIMATION_H 0008 #define KITEMLISTVIEWANIMATION_H 0009 0010 #include "dolphin_export.h" 0011 0012 #include <QHash> 0013 #include <QObject> 0014 #include <QVariant> 0015 0016 class KItemListView; 0017 class QGraphicsWidget; 0018 class QPropertyAnimation; 0019 0020 /** 0021 * @brief Internal helper class for KItemListView to animate the items. 0022 * 0023 * Supports item animations for moving, creating, deleting and resizing 0024 * an item. Several applications can be applied to one item in parallel. 0025 */ 0026 class DOLPHIN_EXPORT KItemListViewAnimation : public QObject 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 enum AnimationType { MovingAnimation, CreateAnimation, DeleteAnimation, ResizeAnimation, IconResizeAnimation, AnimationTypeCount }; 0032 0033 explicit KItemListViewAnimation(QObject *parent = nullptr); 0034 ~KItemListViewAnimation() override; 0035 0036 void setScrollOrientation(Qt::Orientation orientation); 0037 Qt::Orientation scrollOrientation() const; 0038 0039 void setScrollOffset(qreal scrollOffset); 0040 qreal scrollOffset() const; 0041 0042 /** 0043 * Starts the animation of the type \a type for the widget \a widget. If an animation 0044 * of the type is already running, this animation will be stopped before starting 0045 * the new animation. 0046 */ 0047 void start(QGraphicsWidget *widget, AnimationType type, const QVariant &endValue = QVariant()); 0048 0049 /** 0050 * Stops the animation of the type \a type for the widget \a widget. 0051 */ 0052 void stop(QGraphicsWidget *widget, AnimationType type); 0053 0054 /** 0055 * Stops all animations that have been applied to the widget \a widget. 0056 */ 0057 void stop(QGraphicsWidget *widget); 0058 0059 /** 0060 * @return True if the animation of the type \a type has been started 0061 * for the widget \a widget.. 0062 */ 0063 bool isStarted(QGraphicsWidget *widget, AnimationType type) const; 0064 0065 /** 0066 * @return True if any animation has been started for the widget. 0067 */ 0068 bool isStarted(QGraphicsWidget *widget) const; 0069 0070 Q_SIGNALS: 0071 void finished(QGraphicsWidget *widget, KItemListViewAnimation::AnimationType type); 0072 0073 private Q_SLOTS: 0074 void slotFinished(); 0075 0076 private: 0077 Qt::Orientation m_scrollOrientation; 0078 qreal m_scrollOffset; 0079 QHash<QGraphicsWidget *, QPropertyAnimation *> m_animation[AnimationTypeCount]; 0080 }; 0081 0082 #endif