2 This file is part of KOrganizer.
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
25 #ifndef KORG_HISTORY_H
26 #define KORG_HISTORY_H
28 #include <calendarsupport/incidencechanger.h>
30 #include <Akonadi/Collection>
31 #include <Akonadi/Item>
38 class History
: public QObject
42 History( CalendarSupport::Calendar
*, QWidget
*parent
);
44 void recordDelete( const Akonadi::Item
& );
45 void recordAdd( const Akonadi::Item
& );
46 void recordEdit( const Akonadi::Item
&oldItem
,
47 const Akonadi::Item
&newItem
);
48 void startMultiModify( const QString
&description
);
49 void endMultiModify();
56 void incidenceChangeFinished( const Akonadi::Item
&,
57 const Akonadi::Item
&,
58 CalendarSupport::IncidenceChanger::WhatChanged
,
61 void incidenceAddFinished( const Akonadi::Item
&, bool );
63 void incidenceDeleteFinished( const Akonadi::Item
&, bool );
69 void undoAvailable( const QString
& );
70 void redoAvailable( const QString
& );
74 void disableHistory();
76 // Called as soon as the modify jobs finish
77 void finishUndo( bool success
);
78 void finishRedo( bool success
);
82 void addEntry( Entry
*entry
);
89 Entry( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
* );
92 virtual bool undo() = 0;
93 virtual bool redo() = 0;
95 virtual QString
text() = 0;
97 void setItemId( Akonadi::Item::Id
);
98 Akonadi::Item::Id
itemId();
101 CalendarSupport::Calendar
*mCalendar
;
102 CalendarSupport::IncidenceChanger
*mChanger
;
103 Akonadi::Item::Id mItemId
;
106 class EntryDelete
: public Entry
109 EntryDelete( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
*,
110 const Akonadi::Item
& );
120 KCalCore::Incidence::Ptr mIncidence
;
121 Akonadi::Collection mCollection
;
125 class EntryAdd
: public Entry
128 EntryAdd( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
*,
129 const Akonadi::Item
& );
138 KCalCore::Incidence::Ptr mIncidence
;
139 Akonadi::Collection mCollection
;
143 class EntryEdit
: public Entry
146 EntryEdit( CalendarSupport::Calendar
*calendar
,
147 CalendarSupport::IncidenceChanger
*,
148 const Akonadi::Item
&oldItem
,
149 const Akonadi::Item
&newItem
);
158 KCalCore::Incidence::Ptr mOldIncidence
;
159 KCalCore::Incidence::Ptr mNewIncidence
;
162 class MultiEntry
: public Entry
165 MultiEntry( CalendarSupport::Calendar
*calendar
, const QString
&text
);
168 void appendEntry( Entry
*entry
);
173 void itemCreated( Akonadi::Item::Id
);
176 QList
<Entry
*> mEntries
;
180 CalendarSupport::Calendar
*mCalendar
;
181 MultiEntry
*mCurrentMultiEntry
;
183 CalendarSupport::IncidenceChanger
*mChanger
;
185 QStack
<Entry
*> mUndoEntries
;
186 QStack
<Entry
*> mRedoEntries
;
188 // If this is not 0 there's a modify job running that didn't end yet
189 Entry
*mCurrentRunningEntry
;
196 // When the job ends we must know if we were doing a undo or redo
197 Operation mCurrentRunningOperation
;