20 #ifndef AKONADI_HISTORY_P_H
21 #define AKONADI_HISTORY_P_H
24 #include "incidencechanger.h"
25 #include <kcalcore/incidence.h>
26 #include <akonadi/collection.h>
32 using namespace Akonadi;
33 using namespace KCalCore;
45 class Entry :
public QObject {
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);
55 Akonadi::Item::List mItems;
58 void finished(Akonadi::IncidenceChanger::ResultCode,
const QString &errorString);
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;
67 QVector<int> mChangeIds;
69 void init(
const QString &description,
History *qq);
73 class History::Private :
public QObject {
78 void doIt(OperationType);
79 void stackEntry(
const Entry::Ptr &entry, uint atomicOperationId);
80 void updateIds(Item::Id oldId, Item::Id newId);
82 QStack<Entry::Ptr>& destinationStack();
83 QStack<Entry::Ptr>& stack(OperationType);
84 QStack<Entry::Ptr>& stack();
85 void undoOrRedo(OperationType, QWidget *parent);
88 void setEnabled(
bool enabled);
90 bool isUndoAvailable()
const;
91 bool isRedoAvailable()
const;
93 int redoCount()
const;
94 int undoCount()
const;
96 IncidenceChanger *mChanger;
98 QStack<Entry::Ptr> mUndoStack;
99 QStack<Entry::Ptr> mRedoStack;
101 OperationType mOperationTypeInProgress;
103 Entry::Ptr mEntryInProgress;
105 QString mLastErrorString;
106 bool mUndoAllInProgress;
112 QVector<Entry::Ptr> mQueuedEntries;
114 QPointer<QWidget> mCurrentParent;
117 void handleFinished(Akonadi::IncidenceChanger::ResultCode,
const QString &errorString);
123 class CreationEntry :
public Entry {
126 typedef QSharedPointer<CreationEntry> Ptr;
127 CreationEntry(
const Akonadi::Item &item,
const QString &description,
History *q);
136 void onDeleteFinished(
int changeId,
const QVector<Akonadi::Item::Id> &deletedIds,
137 Akonadi::IncidenceChanger::ResultCode resultCode,
138 const QString &errorString);
140 void onCreateFinished(
int changeId,
const Akonadi::Item &item,
141 Akonadi::IncidenceChanger::ResultCode resultCode,
142 const QString &errorString);
144 Q_DISABLE_COPY(CreationEntry)
147 class DeletionEntry :
public Entry {
150 DeletionEntry(
const Akonadi::Item::List &items,
const QString &description,
History *q);
bool undo();
bool redo();
155 void onDeleteFinished(
int changeId,
const QVector<Akonadi::Item::Id> &deletedIds,
156 Akonadi::IncidenceChanger::ResultCode resultCode,
157 const QString &errorString);
159 void onCreateFinished(
int changeId,
const Akonadi::Item &item,
160 Akonadi::IncidenceChanger::ResultCode resultCode,
161 const QString &errorString);
163 IncidenceChanger::ResultCode mResultCode;
164 QString mErrorString;
165 QHash<int,Akonadi::Item::Id> mOldIdByChangeId;
166 int mNumPendingCreations;
167 Q_DISABLE_COPY(DeletionEntry)
170 class ModificationEntry :
public Entry {
173 ModificationEntry(
const Akonadi::Item &item,
174 const Incidence::Ptr &originalPayload,
175 const QString &description,
177 bool undo();
bool redo();
182 void onModifyFinished(
int changeId,
const Akonadi::Item &item,
183 Akonadi::IncidenceChanger::ResultCode resultCode,
184 const QString &errorString);
186 Q_DISABLE_COPY(ModificationEntry)
187 Incidence::Ptr mOriginalPayload;
190 class MultiEntry : public Entry {
193 typedef QSharedPointer<MultiEntry> Ptr;
194 MultiEntry(
int id,
const QString &description,
History *q);
196 void addEntry(
const Entry::Ptr &entry);
void updateIds(Item::Id oldId, Item::Id newId);
201 bool undo();
bool redo();
205 void onEntryFinished(Akonadi::IncidenceChanger::ResultCode resultCode,
206 const QString &errorString);
208 const uint mAtomicOperationId;
210 Entry::List mEntries;
211 int mFinishedEntries;
212 OperationType mOperationInProgress;
213 Q_DISABLE_COPY(MultiEntry)
History class for implementing undo/redo of calendar operations.
ResultCode
This enum describes the possible result codes (success/error values) for an undo or redo operation...