• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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 
89  bool isUndoAvailable() const;
90  bool isRedoAvailable() const;
91 
92  IncidenceChanger *mChanger;
93 
94  QStack<Entry::Ptr> mUndoStack;
95  QStack<Entry::Ptr> mRedoStack;
96 
97  OperationType mOperationTypeInProgress;
98 
99  Entry::Ptr mEntryInProgress;
100 
101  QString mLastErrorString;
102  bool mUndoAllInProgress;
103 
108  QVector<Entry::Ptr> mQueuedEntries;
109  bool mEnabled;
110  QPointer<QWidget> mCurrentParent;
111 
112 public Q_SLOTS:
113  void handleFinished( Akonadi::IncidenceChanger::ResultCode, const QString &errorString );
114 
115 private:
116  History *q;
117 };
118 
119 class CreationEntry : public Entry {
120  Q_OBJECT
121 public:
122  typedef QSharedPointer<CreationEntry> Ptr;
123  CreationEntry( const Akonadi::Item &item, const QString &description, History *q );
124 
126  bool undo();
127 
129  bool redo();
130 
131 private Q_SLOTS:
132  void onDeleteFinished( int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
133  Akonadi::IncidenceChanger::ResultCode resultCode,
134  const QString &errorString );
135 
136  void onCreateFinished( int changeId, const Akonadi::Item &item,
137  Akonadi::IncidenceChanger::ResultCode resultCode,
138  const QString &errorString );
139 private:
140  Q_DISABLE_COPY(CreationEntry)
141 };
142 
143 class DeletionEntry : public Entry {
144  Q_OBJECT
145 public:
146  DeletionEntry( const Akonadi::Item::List &items, const QString &description, History *q ); bool undo(); bool redo();
149 
150 private Q_SLOTS:
151  void onDeleteFinished( int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
152  Akonadi::IncidenceChanger::ResultCode resultCode,
153  const QString &errorString );
154 
155  void onCreateFinished( int changeId, const Akonadi::Item &item,
156  Akonadi::IncidenceChanger::ResultCode resultCode,
157  const QString &errorString );
158 private:
159  IncidenceChanger::ResultCode mResultCode;
160  QString mErrorString;
161  QHash<int,Akonadi::Item::Id> mOldIdByChangeId;
162  int mNumPendingCreations;
163  Q_DISABLE_COPY(DeletionEntry)
164 };
165 
166 class ModificationEntry : public Entry {
167  Q_OBJECT
168 public:
169  ModificationEntry( const Akonadi::Item &item,
170  const Incidence::Ptr &originalPayload,
171  const QString &description,
172  History *q );
173  bool undo(); bool redo();
176 
177 private Q_SLOTS:
178  void onModifyFinished( int changeId, const Akonadi::Item &item,
179  Akonadi::IncidenceChanger::ResultCode resultCode,
180  const QString &errorString );
181 private:
182  Q_DISABLE_COPY(ModificationEntry)
183  Incidence::Ptr mOriginalPayload;
184 };
185 
186 class MultiEntry : public Entry {
187  Q_OBJECT
188 public:
189  typedef QSharedPointer<MultiEntry> Ptr;
190  MultiEntry( int id, const QString &description, History *q );
191 
192  void addEntry( const Entry::Ptr &entry ); void updateIds( Item::Id oldId, Item::Id newId );
194 
195 protected: bool undo(); bool redo();
198 
199 private Q_SLOTS:
200  void onEntryFinished( Akonadi::IncidenceChanger::ResultCode resultCode,
201  const QString &errorString );
202 public:
203  const uint mAtomicOperationId;
204 private:
205  Entry::List mEntries;
206  int mFinishedEntries;
207  OperationType mOperationInProgress;
208  Q_DISABLE_COPY(MultiEntry)
209 };
210 
211 }
212 
213 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:37 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.5 API Reference

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