summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-07-30 14:43:57 (UTC)
committer zautrix <zautrix>2005-07-30 14:43:57 (UTC)
commit9ca2cd947f22d33543e065f54c6487e86d80befa (patch) (unidiff)
tree549192e9e27e8972e2b48cf40e1599118df12da5 /libkcal
parent055928e26613f4ab249bd82be86890ed278372f6 (diff)
downloadkdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.zip
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.gz
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.bz2
fixxx
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp42
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp26
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/incidence.cpp6
-rw-r--r--libkcal/incidence.h1
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
@@ -110,9 +110,28 @@ void Calendar::init()
110Calendar::~Calendar() 110Calendar::~Calendar()
111{ 111{
112 delete mDefaultFilter; 112 delete mDefaultFilter;
113 if ( mUndoIncidence ) 113 clearUndo( 0 );
114 delete mUndoIncidence; 114}
115} 115void 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
116void Calendar::setDontDeleteIncidencesOnClose () 135void Calendar::setDontDeleteIncidencesOnClose ()
117{ 136{
118 mDeleteIncidencesOnClose = false; 137 mDeleteIncidencesOnClose = false;
@@ -447,7 +466,21 @@ void Calendar::removeRelations( Incidence *incidence )
447 incidence->relatedTo()->removeRelation( incidence ); 466 incidence->relatedTo()->removeRelation( 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() ) ) ) {
453 // Removing wasn't that easy 486 // Removing wasn't that easy
@@ -458,6 +491,7 @@ void Calendar::removeRelations( Incidence *incidence )
458 } 491 }
459 } 492 }
460 } 493 }
494#endif
461} 495}
462 496
463void Calendar::registerObserver( Observer *observer ) 497void Calendar::registerObserver( Observer *observer )
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 95477cd..3f6895d 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -80,6 +80,7 @@ public:
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; 80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
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 /**
85 Sync changes in memory to persistant storage. 86 Sync changes in memory to persistant storage.
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index e8c969f..1a1c6be 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -268,20 +268,7 @@ void CalendarLocal::close()
268 268
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}
285bool CalendarLocal::addAnniversaryNoDup( Event *event ) 272bool CalendarLocal::addAnniversaryNoDup( Event *event )
286{ 273{
287 QString cat; 274 QString cat;
@@ -340,8 +327,7 @@ bool CalendarLocal::addEvent( Event *event )
340 327
341void CalendarLocal::deleteEvent( Event *event ) 328void 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 );
347 } 333 }
@@ -395,9 +381,8 @@ bool CalendarLocal::addTodo( Todo *todo )
395void CalendarLocal::deleteTodo( Todo *todo ) 381void 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 ) ) {
403 setModified( true ); 388 setModified( true );
@@ -899,8 +884,7 @@ bool CalendarLocal::addJournal(Journal *journal)
899 884
900void CalendarLocal::deleteJournal( Journal *journal ) 885void 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 );
906 } 890 }
@@ -979,7 +963,7 @@ void CalendarLocal::setCalendarRemove( int id )
979 } 963 }
980 } 964 }
981 965
982 clearUndo(); 966 clearUndo(0);
983 967
984} 968}
985 969
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index ae7e30c..a7a85c8 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -69,7 +69,6 @@ class CalendarLocal : public Calendar
69 Clears out the current calendar, freeing all used memory etc. etc. 69 Clears out the current calendar, freeing all used memory etc. etc.
70 */ 70 */
71 void close(); 71 void close();
72 void clearUndo();
73 72
74 void save() {} 73 void save() {}
75 74
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 52d94fb..549014e 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -491,7 +491,11 @@ void Incidence::setRelatedToUid(const QString &relatedToUid)
491 if (mReadOnly) return; 491 if (mReadOnly) return;
492 mRelatedToUid = relatedToUid; 492 mRelatedToUid = relatedToUid;
493} 493}
494 494void Incidence::clearRelations()
495{
496 mRelatedTo = 0;
497 mRelations.clear();
498}
495QString Incidence::relatedToUid() const 499QString Incidence::relatedToUid() const
496{ 500{
497 return mRelatedToUid; 501 return mRelatedToUid;
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 88df217..eef9e64 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -114,6 +114,7 @@ class Incidence : public IncidenceBase
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
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 );
119 120