• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

  • sources
  • kde-4.12
  • kdelibs
  • kio
  • kio
delegateanimationhandler_p.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE project
3 
4  Copyright © 2007 Fredrik Höglund <fredrik@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef DELEGATEANIMATIONHANDLER_P_H
23 #define DELEGATEANIMATIONHANDLER_P_H
24 
25 #include <QBasicTimer>
26 #include <QMap>
27 #include <QLinkedList>
28 #include <QPersistentModelIndex>
29 #include <QStyle>
30 #include <QTimeLine>
31 #include <QTime>
32 #include <QTimer>
33 
34 
35 class QAbstractItemView;
36 
37 namespace KIO
38 {
39 
40 class CachedRendering : public QObject
41 {
42  Q_OBJECT
43 public:
44 
45  CachedRendering(QStyle::State state, const QSize &size, QModelIndex validityIndex);
46  bool checkValidity(QStyle::State current) const { return state == current && valid; }
47 
48  QStyle::State state;
49  QPixmap regular;
50  QPixmap hover;
51 
52  bool valid;
53  QPersistentModelIndex validityIndex;
54 private Q_SLOTS:
55  void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
56  void modelReset();
57 };
58 
59 
60 class AnimationState
61 {
62 public:
63  ~AnimationState();
64  //Progress of the mouse hovering animation
65  qreal hoverProgress() const;
66  //Progress of the icon fading animation
67  qreal fadeProgress() const;
68  //Angle of the painter, to paint the animation for a file job on an item
69  qreal jobAnimationAngle() const;
70 
71  void setJobAnimation(bool value);
72  bool hasJobAnimation() const;
73 
74  CachedRendering *cachedRendering() const { return renderCache; }
75  //The previous render-cache is deleted, if there was one
76  void setCachedRendering(CachedRendering *rendering) { delete renderCache; renderCache = rendering; }
77 
78  //Returns current cached rendering, and removes it from this state.
79  //The caller has the ownership.
80  CachedRendering *takeCachedRendering() { CachedRendering* ret = renderCache; renderCache = 0; return ret; }
81 
82  CachedRendering* cachedRenderingFadeFrom() const { return fadeFromRenderCache; }
83  //The previous render-cache is deleted, if there was one
84  void setCachedRenderingFadeFrom(CachedRendering* rendering) { delete fadeFromRenderCache; fadeFromRenderCache = rendering; if(rendering) m_fadeProgress = 0; else m_fadeProgress = 1; }
85 
86 private:
87  AnimationState(const QModelIndex &index);
88  bool update();
89 
90  QPersistentModelIndex index;
91  QTimeLine::Direction direction;
92  bool animating;
93  bool jobAnimation;
94  qreal progress;
95  qreal m_fadeProgress;
96  qreal m_jobAnimationAngle;
97  QTime time;
98  QTime creationTime;
99  CachedRendering *renderCache;
100  CachedRendering *fadeFromRenderCache;
101 
102  friend class DelegateAnimationHandler;
103 };
104 
105 
106 class DelegateAnimationHandler : public QObject
107 {
108  Q_OBJECT
109 
110  typedef QLinkedList<AnimationState*> AnimationList;
111  typedef QMapIterator<const QAbstractItemView *, AnimationList*> AnimationListsIterator;
112  typedef QMutableMapIterator<const QAbstractItemView *, AnimationList*> MutableAnimationListsIterator;
113 
114 public:
115  DelegateAnimationHandler(QObject *parent = 0);
116  ~DelegateAnimationHandler();
117 
118  AnimationState *animationState(const QStyleOption &option, const QModelIndex &index, const QAbstractItemView *view);
119 
120  void restartAnimation(AnimationState* state);
121 
122  void gotNewIcon(const QModelIndex& index);
123 
124 private slots:
125  void viewDeleted(QObject *view);
126  void sequenceTimerTimeout();
127 
128 private:
129  void eventuallyStartIteration(QModelIndex index);
130  AnimationState *findAnimationState(const QAbstractItemView *view, const QModelIndex &index) const;
131  void addAnimationState(AnimationState *state, const QAbstractItemView *view);
132  void startAnimation(AnimationState *state);
133  int runAnimations(AnimationList *list, const QAbstractItemView *view);
134  void timerEvent(QTimerEvent *event);
135  void setSequenceIndex(int arg1);
136 
137 private:
138  QMap<const QAbstractItemView*, AnimationList*> animationLists;
139  QTime fadeInAddTime;
140  QBasicTimer timer;
141  //Icon sequence handling:
142  QPersistentModelIndex sequenceModelIndex;
143  QTimer iconSequenceTimer;
144  int currentSequenceIndex;
145 };
146 
147 }
148 
149 #endif
KIO::AnimationState::hoverProgress
qreal hoverProgress() const
Definition: delegateanimationhandler.cpp:153
KIO::CachedRendering::CachedRendering
CachedRendering(QStyle::State state, const QSize &size, QModelIndex validityIndex)
Definition: delegateanimationhandler.cpp:55
KIO::CachedRendering::state
QStyle::State state
Definition: delegateanimationhandler_p.h:48
KIO::DelegateAnimationHandler::restartAnimation
void restartAnimation(AnimationState *state)
Definition: delegateanimationhandler.cpp:384
QObject
KIO::DelegateAnimationHandler::gotNewIcon
void gotNewIcon(const QModelIndex &index)
Definition: delegateanimationhandler.cpp:228
KIO::AnimationState::jobAnimationAngle
qreal jobAnimationAngle() const
Definition: delegateanimationhandler.cpp:166
KIO::CachedRendering::regular
QPixmap regular
Definition: delegateanimationhandler_p.h:49
KIO::AnimationState
Definition: delegateanimationhandler_p.h:60
KIO::AnimationState::setCachedRendering
void setCachedRendering(CachedRendering *rendering)
Definition: delegateanimationhandler_p.h:76
KIO::CachedRendering::hover
QPixmap hover
Definition: delegateanimationhandler_p.h:50
KIO::AnimationState::~AnimationState
~AnimationState()
Definition: delegateanimationhandler.cpp:94
KIO::AnimationState::hasJobAnimation
bool hasJobAnimation() const
Definition: delegateanimationhandler.cpp:171
KIO::CachedRendering::validityIndex
QPersistentModelIndex validityIndex
Definition: delegateanimationhandler_p.h:53
KIO::DelegateAnimationHandler::~DelegateAnimationHandler
~DelegateAnimationHandler()
Definition: delegateanimationhandler.cpp:193
KIO::CachedRendering::valid
bool valid
Definition: delegateanimationhandler_p.h:52
KIO::AnimationState::cachedRenderingFadeFrom
CachedRendering * cachedRenderingFadeFrom() const
Definition: delegateanimationhandler_p.h:82
KIO::AnimationState::fadeProgress
qreal fadeProgress() const
Definition: delegateanimationhandler.cpp:161
KIO::DelegateAnimationHandler::animationState
AnimationState * animationState(const QStyleOption &option, const QModelIndex &index, const QAbstractItemView *view)
Definition: delegateanimationhandler.cpp:271
KIO::DelegateAnimationHandler
Definition: delegateanimationhandler_p.h:106
KIO::AnimationState::setJobAnimation
void setJobAnimation(bool value)
Definition: delegateanimationhandler.cpp:176
KIO::CachedRendering::checkValidity
bool checkValidity(QStyle::State current) const
Definition: delegateanimationhandler_p.h:46
KIO::AnimationState::cachedRendering
CachedRendering * cachedRendering() const
Definition: delegateanimationhandler_p.h:74
KIO::AnimationState::setCachedRenderingFadeFrom
void setCachedRenderingFadeFrom(CachedRendering *rendering)
Definition: delegateanimationhandler_p.h:84
KIO::DelegateAnimationHandler::DelegateAnimationHandler
DelegateAnimationHandler(QObject *parent=0)
Definition: delegateanimationhandler.cpp:185
QSize
KIO::CachedRendering
Definition: delegateanimationhandler_p.h:40
QMap< const QAbstractItemView *, AnimationList * >
KIO::AnimationState::takeCachedRendering
CachedRendering * takeCachedRendering()
Definition: delegateanimationhandler_p.h:80
KRecentDirs::list
QStringList list(const QString &fileClass)
Returns a list of directories associated with this file-class.
Definition: krecentdirs.cpp:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal