-rw-r--r-- | libkcal/calendar.cpp | 11 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 17 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
5 files changed, 39 insertions, 7 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 52daaaa..88351eb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -52,7 +52,7 @@ void Calendar::init() | |||
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | 55 | mUndoIncidence = 0; | |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
@@ -109,6 +109,8 @@ void Calendar::init() | |||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | ||
113 | delete mUndoIncidence; | ||
112 | } | 114 | } |
113 | 115 | ||
114 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
@@ -116,6 +118,13 @@ const QString &Calendar::getOwner() const | |||
116 | return mOwner; | 118 | return mOwner; |
117 | } | 119 | } |
118 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | ||
122 | { | ||
123 | if (!mUndoIncidence) | ||
124 | return false; | ||
125 | addIncidence(mUndoIncidence); | ||
126 | mUndoIncidence = 0; | ||
127 | } | ||
119 | void Calendar::setOwner(const QString &os) | 128 | void Calendar::setOwner(const QString &os) |
120 | { | 129 | { |
121 | int i; | 130 | int i; |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b7d6a1f..2f2c3aa 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -65,6 +65,8 @@ public: | |||
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | ||
69 | bool undoDeleteIncidence(); | ||
68 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
70 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
@@ -322,6 +324,7 @@ public: | |||
322 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 324 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
323 | bool inclusive = false ) = 0; | 325 | bool inclusive = false ) = 0; |
324 | Incidence *mNextAlarmIncidence; | 326 | Incidence *mNextAlarmIncidence; |
327 | Incidence *mUndoIncidence; | ||
325 | 328 | ||
326 | private: | 329 | private: |
327 | void init(); | 330 | void init(); |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3f46d53..12294c0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -152,11 +152,11 @@ bool CalendarLocal::addEvent( Event *event ) | |||
152 | 152 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | if ( mUndoIncidence ) delete mUndoIncidence; | |
156 | 156 | mUndoIncidence = event->clone(); | |
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
@@ -201,7 +201,9 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | if ( mUndoIncidence ) delete mUndoIncidence; |
205 | mUndoIncidence = todo->clone(); | ||
206 | removeRelations( todo ); | ||
205 | 207 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 208 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 209 | setModified( true ); |
@@ -687,6 +689,9 @@ bool CalendarLocal::addJournal(Journal *journal) | |||
687 | 689 | ||
688 | void CalendarLocal::deleteJournal( Journal *journal ) | 690 | void CalendarLocal::deleteJournal( Journal *journal ) |
689 | { | 691 | { |
692 | if ( mUndoIncidence ) delete mUndoIncidence; | ||
693 | mUndoIncidence = journal->clone(); | ||
694 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | ||
690 | if ( mJournalList.removeRef(journal) ) { | 695 | if ( mJournalList.removeRef(journal) ) { |
691 | setModified( true ); | 696 | setModified( true ); |
692 | } | 697 | } |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 5a9ef0e..28402ae 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -173,6 +173,20 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
173 | stringCompare( i1.location(), i2.location() ); | 173 | stringCompare( i1.location(), i2.location() ); |
174 | } | 174 | } |
175 | 175 | ||
176 | Incidence* Incidence::recreateCloneException( QDate d ) | ||
177 | { | ||
178 | Incidence* newInc = clone(); | ||
179 | newInc->recreate(); | ||
180 | if ( doesRecur() ) { | ||
181 | addExDate( d ); | ||
182 | newInc->recurrence()->unsetRecurs(); | ||
183 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | ||
184 | QTime tim = dtStart().time(); | ||
185 | newInc->setDtStart( QDateTime(d, tim) ); | ||
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | ||
187 | } | ||
188 | return newInc; | ||
189 | } | ||
176 | 190 | ||
177 | void Incidence::recreate() | 191 | void Incidence::recreate() |
178 | { | 192 | { |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 7dc6f10..1807bc4 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -122,6 +122,7 @@ class Incidence : public IncidenceBase | |||
122 | modification date and revision number. | 122 | modification date and revision number. |
123 | */ | 123 | */ |
124 | void recreate(); | 124 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | ||
125 | 126 | ||
126 | /** set creation date */ | 127 | /** set creation date */ |
127 | void setCreated(QDateTime); | 128 | void setCreated(QDateTime); |