• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
32using namespace Akonadi;
33using namespace KCalCore;
34
35namespace Akonadi {
36
37class History;
38
39enum OperationType {
40 TypeNone,
41 TypeUndo,
42 TypeRedo
43};
44
45class Entry : public QObject {
46 Q_OBJECT
47public:
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;
57Q_SIGNALS:
58 void finished(Akonadi::IncidenceChanger::ResultCode, const QString &errorString);
59protected:
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;
68private:
69 void init(const QString &description, History *qq);
70 Q_DISABLE_COPY(Entry)
71};
72
73class History::Private : public QObject {
74 Q_OBJECT
75public:
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 int redoCount() const;
94 int undoCount() const;
95
96 IncidenceChanger *mChanger;
97
98 QStack<Entry::Ptr> mUndoStack;
99 QStack<Entry::Ptr> mRedoStack;
100
101 OperationType mOperationTypeInProgress;
102
103 Entry::Ptr mEntryInProgress;
104
105 QString mLastErrorString;
106 bool mUndoAllInProgress;
107
112 QVector<Entry::Ptr> mQueuedEntries;
113 bool mEnabled;
114 QPointer<QWidget> mCurrentParent;
115
116public Q_SLOTS:
117 void handleFinished(Akonadi::IncidenceChanger::ResultCode, const QString &errorString);
118
119private:
120 History *q;
121};
122
123class CreationEntry : public Entry {
124 Q_OBJECT
125public:
126 typedef QSharedPointer<CreationEntry> Ptr;
127 CreationEntry(const Akonadi::Item &item, const QString &description, History *q);
128
130 bool undo();
131
133 bool redo();
134
135private Q_SLOTS:
136 void onDeleteFinished(int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
137 Akonadi::IncidenceChanger::ResultCode resultCode,
138 const QString &errorString);
139
140 void onCreateFinished(int changeId, const Akonadi::Item &item,
141 Akonadi::IncidenceChanger::ResultCode resultCode,
142 const QString &errorString);
143private:
144 Q_DISABLE_COPY(CreationEntry)
145};
146
147class DeletionEntry : public Entry {
148 Q_OBJECT
149public:
150 DeletionEntry(const Akonadi::Item::List &items, const QString &description, History *q); bool undo(); bool redo();
153
154private Q_SLOTS:
155 void onDeleteFinished(int changeId, const QVector<Akonadi::Item::Id> &deletedIds,
156 Akonadi::IncidenceChanger::ResultCode resultCode,
157 const QString &errorString);
158
159 void onCreateFinished(int changeId, const Akonadi::Item &item,
160 Akonadi::IncidenceChanger::ResultCode resultCode,
161 const QString &errorString);
162private:
163 IncidenceChanger::ResultCode mResultCode;
164 QString mErrorString;
165 QHash<int,Akonadi::Item::Id> mOldIdByChangeId;
166 int mNumPendingCreations;
167 Q_DISABLE_COPY(DeletionEntry)
168};
169
170class ModificationEntry : public Entry {
171 Q_OBJECT
172public:
173 ModificationEntry(const Akonadi::Item &item,
174 const Incidence::Ptr &originalPayload,
175 const QString &description,
176 History *q);
177 bool undo(); bool redo();
180
181private Q_SLOTS:
182 void onModifyFinished(int changeId, const Akonadi::Item &item,
183 Akonadi::IncidenceChanger::ResultCode resultCode,
184 const QString &errorString);
185private:
186 Q_DISABLE_COPY(ModificationEntry)
187 Incidence::Ptr mOriginalPayload;
188};
189
190class MultiEntry : public Entry {
191 Q_OBJECT
192public:
193 typedef QSharedPointer<MultiEntry> Ptr;
194 MultiEntry(int id, const QString &description, History *q);
195
196 void addEntry(const Entry::Ptr &entry); void updateIds(Item::Id oldId, Item::Id newId);
198
199protected:
201 bool undo(); bool redo();
203
204private Q_SLOTS:
205 void onEntryFinished(Akonadi::IncidenceChanger::ResultCode resultCode,
206 const QString &errorString);
207public:
208 const uint mAtomicOperationId;
209private:
210 Entry::List mEntries;
211 int mFinishedEntries;
212 OperationType mOperationInProgress;
213 Q_DISABLE_COPY(MultiEntry)
214};
215
216}
217
218#endif
Akonadi::History
History class for implementing undo/redo of calendar operations.
Definition: history.h:58
Akonadi::History::ResultCode
ResultCode
This enum describes the possible result codes (success/error values) for an undo or redo operation.
Definition: history.h:67
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.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.14.10 API Reference

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