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

akonadi

  • akonadi
  • calendar
history_p.h
1 /*
2  Copyright (C) 2010-2012 Sérgio Martins <iamsergio@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef AKONADI_HISTORY_P_H
21 #define AKONADI_HISTORY_P_H
22 
23 #include "history.h"
24 #include "incidencechanger.h"
25 #include <kcalcore/incidence.h>
26 #include <akonadi/collection.h>
27 
28 #include <QPointer>
29 #include <QStack>
30 #include <QVector>
31 
32 using namespace Akonadi;
33 using namespace KCalCore;
34 
35 namespace Akonadi {
36 
37 class History;
38 
39 enum OperationType {
40  TypeNone,
41  TypeUndo,
42  TypeRedo
43 };
44 
45 class Entry : public QObject {
46  Q_OBJECT
47 public:
48  typedef QSharedPointer<Entry> Ptr;
49  typedef QVector<Entry::Ptr> List;
50  Entry( const Akonadi::Item &item, const QString &description, History *qq );
51  Entry( const Akonadi::Item::List &items, const QString &description, History *qq );
52  virtual void updateIds( Item::Id oldId, Item::Id newId );
53  void doIt( OperationType );
54 
55  Akonadi::Item::List mItems;
56  QString mDescription;
57 Q_SIGNALS:
58  void finished( Akonadi::IncidenceChanger::ResultCode, const QString &errorString );
59 protected:
60  virtual bool undo() = 0;
61  virtual bool redo() = 0;
62  void updateIdsGlobaly(Item::Id oldId, Item::Id newId);
63  QWidget* currentParent() const;
64  IncidenceChanger *mChanger;
65  QHash<Akonadi::Item::Id,int> mLatestRevisionByItemId;
66  History *q;
67  QVector<int> mChangeIds;
68 private:
69  void init( const QString &description, History *qq );
70  Q_DISABLE_COPY(Entry)
71 };
72 
73 class History::Private : public QObject {
74  Q_OBJECT
75 public:
76  Private( History *qq );
77  ~Private(){}
78  void doIt( OperationType );
79  void stackEntry( const Entry::Ptr &entry, uint atomicOperationId );
80  void updateIds( Item::Id oldId, Item::Id newId );
81  void finishOperation( int changeId, History::ResultCode, const QString &errorString );
82  QStack<Entry::Ptr>& destinationStack();
83  QStack<Entry::Ptr>& stack( OperationType );
84  QStack<Entry::Ptr>& stack();
85  void undoOrRedo( OperationType, QWidget *parent );
86 
87  void emitDone( OperationType, History::ResultCode );
88  void setEnabled( bool enabled );
89 
90  bool isUndoAvailable() const;
91  bool isRedoAvailable() const;
92 
93  IncidenceChanger *mChanger;
94 
95  QStack<Entry::Ptr> mUndoStack;
96  QStack<Entry::Ptr> mRedoStack;
97 
98  OperationType mOperationTypeInProgress;
99 
100  Entry::Ptr mEntryInProgress;
101 
102  QString mLastErrorString;
103  bool mUndoAllInProgress;
104 
109  QVector<Entry::Ptr> mQueuedEntries;
110  bool mEnabled;
111  QPointer<QWidget> mCurrentParent;
112 
113 public Q_SLOTS:
114  void handleFinished( Akonadi::IncidenceChanger::ResultCode, const QString &errorString );
115 
116 private:
117  History *q;
118 };
119 
120 class CreationEntry : public Entry {
121  Q_OBJECT
122 public:
123  typedef QSharedPointer<CreationEntry> Ptr;
124  CreationEntry( const Akonadi::Item &item, const QString &description, History *q );
125 
127  bool undo();
128 
130  bool redo();
131 
132 private Q_SLOTS:
133  void onDeleteFinished( int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
134  Akonadi::IncidenceChanger::ResultCode resultCode,
135  const QString &errorString );
136 
137  void onCreateFinished( int changeId, const Akonadi::Item &item,
138  Akonadi::IncidenceChanger::ResultCode resultCode,
139  const QString &errorString );
140 private:
141  Q_DISABLE_COPY(CreationEntry)
142 };
143 
144 class DeletionEntry : public Entry {
145  Q_OBJECT
146 public:
147  DeletionEntry( const Akonadi::Item::List &items, const QString &description, History *q ); bool undo(); bool redo();
150 
151 private Q_SLOTS:
152  void onDeleteFinished( int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
153  Akonadi::IncidenceChanger::ResultCode resultCode,
154  const QString &errorString );
155 
156  void onCreateFinished( int changeId, const Akonadi::Item &item,
157  Akonadi::IncidenceChanger::ResultCode resultCode,
158  const QString &errorString );
159 private:
160  IncidenceChanger::ResultCode mResultCode;
161  QString mErrorString;
162  QHash<int,Akonadi::Item::Id> mOldIdByChangeId;
163  int mNumPendingCreations;
164  Q_DISABLE_COPY(DeletionEntry)
165 };
166 
167 class ModificationEntry : public Entry {
168  Q_OBJECT
169 public:
170  ModificationEntry( const Akonadi::Item &item,
171  const Incidence::Ptr &originalPayload,
172  const QString &description,
173  History *q );
174  bool undo(); bool redo();
177 
178 private Q_SLOTS:
179  void onModifyFinished( int changeId, const Akonadi::Item &item,
180  Akonadi::IncidenceChanger::ResultCode resultCode,
181  const QString &errorString );
182 private:
183  Q_DISABLE_COPY(ModificationEntry)
184  Incidence::Ptr mOriginalPayload;
185 };
186 
187 class MultiEntry : public Entry {
188  Q_OBJECT
189 public:
190  typedef QSharedPointer<MultiEntry> Ptr;
191  MultiEntry( int id, const QString &description, History *q );
192 
193  void addEntry( const Entry::Ptr &entry ); void updateIds( Item::Id oldId, Item::Id newId );
195 
196 protected: bool undo(); bool redo();
199 
200 private Q_SLOTS:
201  void onEntryFinished( Akonadi::IncidenceChanger::ResultCode resultCode,
202  const QString &errorString );
203 public:
204  const uint mAtomicOperationId;
205 private:
206  Entry::List mEntries;
207  int mFinishedEntries;
208  OperationType mOperationInProgress;
209  Q_DISABLE_COPY(MultiEntry)
210 };
211 
212 }
213 
214 #endif
Akonadi::History
History class for implementing undo/redo of calendar operations.
Definition: history.h:56
Akonadi::History::ResultCode
ResultCode
This enum describes the possible result codes (success/error values) for an undo or redo operation...
Definition: history.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:17 by doxygen 1.8.5 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.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 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