korganizer

history.h
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
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.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24#ifndef KORG_HISTORY_H
25#define KORG_HISTORY_H
26
27#include <tqobject.h>
28#include <tqptrlist.h>
29
30namespace KCal {
31
32class Calendar;
33class Incidence;
34
35}
36
37namespace KOrg {
38
39class History : public TQObject
40{
41 TQ_OBJECT
42
43 public:
44 History( KCal::Calendar * );
45
46 void recordDelete( KCal::Incidence * );
47 void recordAdd( KCal::Incidence * );
48 void recordEdit( KCal::Incidence *oldIncidence,
49 KCal::Incidence *newIncidence );
50 void startMultiModify( const TQString &description );
51 void endMultiModify();
52
53 public slots:
54 void undo();
55 void redo();
56
57 signals:
58 void undone();
59 void redone();
60
61 void undoAvailable( const TQString & );
62 void redoAvailable( const TQString & );
63
64 protected:
65 void truncate();
66
67 private:
68
69 class Entry
70 {
71 public:
72 Entry( KCal::Calendar * );
73 virtual ~Entry();
74
75 virtual void undo() = 0;
76 virtual void redo() = 0;
77
78 virtual TQString text() = 0;
79
80 protected:
81 KCal::Calendar *mCalendar;
82 };
83
84 class EntryDelete : public Entry
85 {
86 public:
87 EntryDelete( KCal::Calendar *, KCal::Incidence * );
88 ~EntryDelete();
89
90 void undo();
91 void redo();
92
93 TQString text();
94
95 private:
96 KCal::Incidence *mIncidence;
97 };
98
99 class EntryAdd : public Entry
100 {
101 public:
102 EntryAdd( KCal::Calendar *, KCal::Incidence * );
103 ~EntryAdd();
104
105 void undo();
106 void redo();
107
108 TQString text();
109
110 private:
111 KCal::Incidence *mIncidence;
112 };
113
114 class EntryEdit : public Entry
115 {
116 public:
117 EntryEdit( KCal::Calendar *calendar, KCal::Incidence *oldIncidence,
118 KCal::Incidence *newIncidence );
119 ~EntryEdit();
120
121 void undo();
122 void redo();
123
124 TQString text();
125
126 private:
127 KCal::Incidence *mOldIncidence;
128 KCal::Incidence *mNewIncidence;
129 };
130
131 class MultiEntry : public Entry
132 {
133 public:
134 MultiEntry( KCal::Calendar *calendar, const TQString &text );
135 ~MultiEntry();
136
137 void appendEntry( Entry* entry );
138 void undo();
139 void redo();
140
141 TQString text();
142
143 private:
144 TQPtrList<Entry> mEntries;
145 TQString mText;
146 };
147
148 KCal::Calendar *mCalendar;
149 MultiEntry *mCurrentMultiEntry;
150
151 TQPtrList<Entry> mEntries;
152 TQPtrListIterator<Entry> mUndoEntry;
153 TQPtrListIterator<Entry> mRedoEntry;
154};
155
156}
157#endif