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.
24 #ifndef KORG_HISTORY_H
25 #define KORG_HISTORY_H
27 #include <calendarsupport/incidencechanger.h>
29 #include <Akonadi/Item>
30 #include <Akonadi/Collection>
32 #include <KCalCore/Incidence>
38 namespace CalendarSupport
{
44 class History
: public QObject
48 History( CalendarSupport::Calendar
*, QWidget
*parent
);
50 void recordDelete( const Akonadi::Item
& );
51 void recordAdd( const Akonadi::Item
& );
52 void recordEdit( const Akonadi::Item
&oldItem
,
53 const Akonadi::Item
&newItem
);
54 void startMultiModify( const QString
&description
);
55 void endMultiModify();
61 void incidenceChangeFinished( const Akonadi::Item
&,
62 const Akonadi::Item
&,
63 CalendarSupport::IncidenceChanger::WhatChanged
,
66 void incidenceAddFinished( const Akonadi::Item
&, bool );
68 void incidenceDeleteFinished( const Akonadi::Item
&, bool );
74 void undoAvailable( const QString
& );
75 void redoAvailable( const QString
& );
79 void disableHistory();
81 // Called as soon as the modify jobs finish
82 void finishUndo( bool success
);
83 void finishRedo( bool success
);
87 void addEntry( Entry
*entry
);
94 Entry( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
* );
97 virtual bool undo() = 0;
98 virtual bool redo() = 0;
100 virtual QString
text() = 0;
102 void setItemId( Akonadi::Item::Id
);
103 Akonadi::Item::Id
itemId();
106 CalendarSupport::Calendar
*mCalendar
;
107 CalendarSupport::IncidenceChanger
*mChanger
;
108 Akonadi::Item::Id mItemId
;
111 class EntryDelete
: public Entry
114 EntryDelete( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
*, const Akonadi::Item
& );
123 KCalCore::Incidence::Ptr mIncidence
;
124 Akonadi::Collection mCollection
;
128 class EntryAdd
: public Entry
131 EntryAdd( CalendarSupport::Calendar
*, CalendarSupport::IncidenceChanger
*, const Akonadi::Item
& );
139 KCalCore::Incidence::Ptr mIncidence
;
140 Akonadi::Collection mCollection
;
144 class EntryEdit
: public Entry
147 EntryEdit( CalendarSupport::Calendar
*calendar
,
148 CalendarSupport::IncidenceChanger
*,
149 const Akonadi::Item
&oldItem
,
150 const Akonadi::Item
&newItem
);
159 KCalCore::Incidence::Ptr mOldIncidence
;
160 KCalCore::Incidence::Ptr mNewIncidence
;
163 class MultiEntry
: public Entry
166 MultiEntry( CalendarSupport::Calendar
*calendar
, const QString
&text
);
169 void appendEntry( Entry
*entry
);
174 void itemCreated( Akonadi::Item::Id
);
177 QList
<Entry
*> mEntries
;
181 CalendarSupport::Calendar
*mCalendar
;
182 MultiEntry
*mCurrentMultiEntry
;
184 CalendarSupport::IncidenceChanger
*mChanger
;
186 QStack
<Entry
*> mUndoEntries
;
187 QStack
<Entry
*> mRedoEntries
;
189 // If this is not 0 there's a modify job running that didn't end yet
190 Entry
*mCurrentRunningEntry
;
197 // When the job ends we must know if we were doing a undo or redo
198 Operation mCurrentRunningOperation
;