-rw-r--r-- | libkcal/calendar.cpp | 42 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 26 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
6 files changed, 50 insertions, 27 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index b7990d4..b1806ee 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -111,7 +111,26 @@ Calendar::~Calendar() | |||
111 | { | 111 | { |
112 | delete mDefaultFilter; | 112 | delete mDefaultFilter; |
113 | if ( mUndoIncidence ) | 113 | clearUndo( 0 ); |
114 | delete mUndoIncidence; | 114 | } |
115 | } | 115 | void Calendar::clearUndo( Incidence * newUndo ) |
116 | { | ||
117 | |||
118 | if ( mUndoIncidence ) { | ||
119 | if ( mUndoIncidence->typeID() == eventID ) | ||
120 | delete ((Event*) mUndoIncidence) ; | ||
121 | else if ( mUndoIncidence->typeID() == todoID ) | ||
122 | delete ( (Todo*) mUndoIncidence ); | ||
123 | else if ( mUndoIncidence->typeID() == journalID ) | ||
124 | delete ( (Journal*) mUndoIncidence ); | ||
125 | else | ||
126 | delete mUndoIncidence; | ||
127 | } | ||
128 | mUndoIncidence = newUndo; | ||
129 | if ( mUndoIncidence ) { | ||
130 | mUndoIncidence->clearRelations(); | ||
131 | } | ||
132 | |||
133 | } | ||
134 | |||
116 | void Calendar::setDontDeleteIncidencesOnClose () | 135 | void Calendar::setDontDeleteIncidencesOnClose () |
117 | { | 136 | { |
@@ -448,5 +467,19 @@ void Calendar::removeRelations( Incidence *incidence ) | |||
448 | 467 | ||
449 | // Remove this one from the orphans list | 468 | // Remove this one from the orphans list |
450 | if( mOrphanUids.remove( uid ) ) | 469 | if( mOrphanUids.remove( uid ) ) { |
470 | QString r2uid = incidence->relatedToUid(); | ||
471 | QPtrList<Incidence> tempList; | ||
472 | while( Incidence* i = mOrphans[ r2uid ] ) { | ||
473 | mOrphans.remove( r2uid ); | ||
474 | if ( i != incidence ) tempList.append( i ); | ||
475 | } | ||
476 | Incidence* inc = tempList.first(); | ||
477 | while ( inc ) { | ||
478 | mOrphans.insert( r2uid, inc ); | ||
479 | inc = tempList.next(); | ||
480 | } | ||
481 | } | ||
482 | // LR: and another big bad bug found | ||
483 | #if 0 | ||
451 | // This incidence is located in the orphans list - it should be removed | 484 | // This incidence is located in the orphans list - it should be removed |
452 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 485 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
@@ -459,4 +492,5 @@ void Calendar::removeRelations( Incidence *incidence ) | |||
459 | } | 492 | } |
460 | } | 493 | } |
494 | #endif | ||
461 | } | 495 | } |
462 | 496 | ||
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 95477cd..3f6895d 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -81,4 +81,5 @@ public: | |||
81 | virtual void setSyncEventsReadOnly() = 0; | 81 | virtual void setSyncEventsReadOnly() = 0; |
82 | virtual void stopAllTodos() = 0; | 82 | virtual void stopAllTodos() = 0; |
83 | virtual void clearUndo( Incidence * newUndo ); | ||
83 | 84 | ||
84 | /** | 85 | /** |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e8c969f..1a1c6be 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -269,18 +269,5 @@ void CalendarLocal::close() | |||
269 | setModified( false ); | 269 | setModified( false ); |
270 | } | 270 | } |
271 | void CalendarLocal::clearUndo() | 271 | |
272 | { | ||
273 | if ( mUndoIncidence ) { | ||
274 | if ( mUndoIncidence->typeID() == eventID ) | ||
275 | delete ((Event*) mUndoIncidence) ; | ||
276 | else if ( mUndoIncidence->typeID() == todoID ) | ||
277 | delete ( (Todo*) mUndoIncidence ); | ||
278 | else if ( mUndoIncidence->typeID() == journalID ) | ||
279 | delete ( (Journal*) mUndoIncidence ); | ||
280 | else | ||
281 | delete mUndoIncidence; | ||
282 | } | ||
283 | mUndoIncidence = 0; | ||
284 | } | ||
285 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 272 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
286 | { | 273 | { |
@@ -341,6 +328,5 @@ bool CalendarLocal::addEvent( Event *event ) | |||
341 | void CalendarLocal::deleteEvent( Event *event ) | 328 | void CalendarLocal::deleteEvent( Event *event ) |
342 | { | 329 | { |
343 | clearUndo(); | 330 | clearUndo(event); |
344 | mUndoIncidence = event; | ||
345 | if ( mEventList.removeRef( event ) ) { | 331 | if ( mEventList.removeRef( event ) ) { |
346 | setModified( true ); | 332 | setModified( true ); |
@@ -396,7 +382,6 @@ void CalendarLocal::deleteTodo( Todo *todo ) | |||
396 | { | 382 | { |
397 | // Handle orphaned children | 383 | // Handle orphaned children |
398 | clearUndo(); | ||
399 | removeRelations( todo ); | 384 | removeRelations( todo ); |
400 | mUndoIncidence = todo; | 385 | clearUndo(todo); |
401 | 386 | ||
402 | if ( mTodoList.removeRef( todo ) ) { | 387 | if ( mTodoList.removeRef( todo ) ) { |
@@ -900,6 +885,5 @@ bool CalendarLocal::addJournal(Journal *journal) | |||
900 | void CalendarLocal::deleteJournal( Journal *journal ) | 885 | void CalendarLocal::deleteJournal( Journal *journal ) |
901 | { | 886 | { |
902 | clearUndo(); | 887 | clearUndo(journal); |
903 | mUndoIncidence = journal; | ||
904 | if ( mJournalList.removeRef(journal) ) { | 888 | if ( mJournalList.removeRef(journal) ) { |
905 | setModified( true ); | 889 | setModified( true ); |
@@ -980,5 +964,5 @@ void CalendarLocal::setCalendarRemove( int id ) | |||
980 | } | 964 | } |
981 | 965 | ||
982 | clearUndo(); | 966 | clearUndo(0); |
983 | 967 | ||
984 | } | 968 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index ae7e30c..a7a85c8 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -70,5 +70,4 @@ class CalendarLocal : public Calendar | |||
70 | */ | 70 | */ |
71 | void close(); | 71 | void close(); |
72 | void clearUndo(); | ||
73 | 72 | ||
74 | void save() {} | 73 | void save() {} |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 52d94fb..549014e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -492,5 +492,9 @@ void Incidence::setRelatedToUid(const QString &relatedToUid) | |||
492 | mRelatedToUid = relatedToUid; | 492 | mRelatedToUid = relatedToUid; |
493 | } | 493 | } |
494 | 494 | void Incidence::clearRelations() | |
495 | { | ||
496 | mRelatedTo = 0; | ||
497 | mRelations.clear(); | ||
498 | } | ||
495 | QString Incidence::relatedToUid() const | 499 | QString Incidence::relatedToUid() const |
496 | { | 500 | { |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 88df217..eef9e64 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -115,4 +115,5 @@ class Incidence : public IncidenceBase | |||
115 | virtual void cloneRelations( Incidence * ); | 115 | virtual void cloneRelations( Incidence * ); |
116 | void addRelationsToList(QPtrList<Incidence> *rel); | 116 | void addRelationsToList(QPtrList<Incidence> *rel); |
117 | void clearRelations(); | ||
117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; | 118 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; |
118 | void setReadOnly( bool ); | 119 | void setReadOnly( bool ); |