• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.2 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
progressspinnerdelegate_p.h
1 /*
2  Copyright (C) 2010 Klarälvdalens Datakonsult AB,
3  a KDAB Group company, info@kdab.net,
4  author Stephen Kelly <stephen@kdab.com>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  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 the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #ifndef PROGRESSSPINNERDELEGATE_P_H
23 #define PROGRESSSPINNERDELEGATE_P_H
24 
25 #include <QStyledItemDelegate>
26 #include <QSet>
27 
28 #include <kpixmapsequence.h>
29 
30 namespace Akonadi {
31 
32 class DelegateAnimator : public QObject
33 {
34  Q_OBJECT
35 public:
36  DelegateAnimator(QAbstractItemView *view);
37 
38  void push(const QModelIndex &index) {
39  if (m_animations.isEmpty())
40  m_timerId = startTimer(200);
41  m_animations.insert(Animation(index));
42  }
43  void pop(const QModelIndex &index) {
44  m_animations.remove(Animation(index));
45  if (m_animations.isEmpty() && m_timerId != -1) {
46  killTimer(m_timerId);
47  m_timerId = -1;
48  }
49  }
50 
51  QPixmap sequenceFrame(const QModelIndex &index);
52 
53  static const int sCount = 7;
54  struct Animation {
55  inline Animation(const QPersistentModelIndex &idx)
56  : frame(0), index(idx)
57  {
58  }
59 
60  bool operator==(const Animation &other) const
61  { return index == other.index; }
62 
63 
64  inline void animate() const { frame = ( frame + 1 ) % sCount; }
65  mutable int frame;
66  QPersistentModelIndex index;
67  };
68 
69 protected:
70  virtual void timerEvent(QTimerEvent *event);
71 
72 private:
73 
74  mutable QSet<Animation> m_animations;
75  QAbstractItemView *m_view;
76  KPixmapSequence m_pixmapSequence;
77  int m_timerId;
78 };
79 
80 uint qHash(Akonadi::DelegateAnimator::Animation anim);
81 
85 class ProgressSpinnerDelegate : public QStyledItemDelegate
86 {
87  Q_OBJECT
88 public:
89  explicit ProgressSpinnerDelegate(DelegateAnimator *animator, QObject* parent = 0);
90 
91 protected:
92  virtual void initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const;
93 
94 private:
95  DelegateAnimator *m_animator;
96 };
97 
98 }
99 
100 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Thu Apr 11 2013 00:44:41 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

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

kdepimlibs-4.10.2 API Reference

Skip menu "kdepimlibs-4.10.2 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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