00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KORG_HISTORY_H
00025 #define KORG_HISTORY_H
00026
00027 #include <tqobject.h>
00028 #include <tqptrlist.h>
00029
00030 namespace KCal {
00031
00032 class Calendar;
00033 class Incidence;
00034
00035 }
00036
00037 namespace KOrg {
00038
00039 class History : public TQObject
00040 {
00041 Q_OBJECT
00042 TQ_OBJECT
00043 public:
00044 History( KCal::Calendar * );
00045
00046 void recordDelete( KCal::Incidence * );
00047 void recordAdd( KCal::Incidence * );
00048 void recordEdit( KCal::Incidence *oldIncidence,
00049 KCal::Incidence *newIncidence );
00050 void startMultiModify( const TQString &description );
00051 void endMultiModify();
00052
00053 public slots:
00054 void undo();
00055 void redo();
00056
00057 signals:
00058 void undone();
00059 void redone();
00060
00061 void undoAvailable( const TQString & );
00062 void redoAvailable( const TQString & );
00063
00064 protected:
00065 void truncate();
00066
00067 private:
00068
00069 class Entry
00070 {
00071 public:
00072 Entry( KCal::Calendar * );
00073 virtual ~Entry();
00074
00075 virtual void undo() = 0;
00076 virtual void redo() = 0;
00077
00078 virtual TQString text() = 0;
00079
00080 protected:
00081 KCal::Calendar *mCalendar;
00082 };
00083
00084 class EntryDelete : public Entry
00085 {
00086 public:
00087 EntryDelete( KCal::Calendar *, KCal::Incidence * );
00088 ~EntryDelete();
00089
00090 void undo();
00091 void redo();
00092
00093 TQString text();
00094
00095 private:
00096 KCal::Incidence *mIncidence;
00097 };
00098
00099 class EntryAdd : public Entry
00100 {
00101 public:
00102 EntryAdd( KCal::Calendar *, KCal::Incidence * );
00103 ~EntryAdd();
00104
00105 void undo();
00106 void redo();
00107
00108 TQString text();
00109
00110 private:
00111 KCal::Incidence *mIncidence;
00112 };
00113
00114 class EntryEdit : public Entry
00115 {
00116 public:
00117 EntryEdit( KCal::Calendar *calendar, KCal::Incidence *oldIncidence,
00118 KCal::Incidence *newIncidence );
00119 ~EntryEdit();
00120
00121 void undo();
00122 void redo();
00123
00124 TQString text();
00125
00126 private:
00127 KCal::Incidence *mOldIncidence;
00128 KCal::Incidence *mNewIncidence;
00129 };
00130
00131 class MultiEntry : public Entry
00132 {
00133 public:
00134 MultiEntry( KCal::Calendar *calendar, const TQString &text );
00135 ~MultiEntry();
00136
00137 void appendEntry( Entry* entry );
00138 void undo();
00139 void redo();
00140
00141 TQString text();
00142
00143 private:
00144 TQPtrList<Entry> mEntries;
00145 TQString mText;
00146 };
00147
00148 KCal::Calendar *mCalendar;
00149 MultiEntry *mCurrentMultiEntry;
00150
00151 TQPtrList<Entry> mEntries;
00152 TQPtrListIterator<Entry> mUndoEntry;
00153 TQPtrListIterator<Entry> mRedoEntry;
00154 };
00155
00156 }
00157 #endif