summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp38
-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, 48 insertions, 25 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()
{
delete mDefaultFilter;
- if ( mUndoIncidence )
+ clearUndo( 0 );
+}
+void Calendar::clearUndo( Incidence * newUndo )
+{
+
+ if ( mUndoIncidence ) {
+ if ( mUndoIncidence->typeID() == eventID )
+ delete ((Event*) mUndoIncidence) ;
+ else if ( mUndoIncidence->typeID() == todoID )
+ delete ( (Todo*) mUndoIncidence );
+ else if ( mUndoIncidence->typeID() == journalID )
+ delete ( (Journal*) mUndoIncidence );
+ else
delete mUndoIncidence;
}
+ mUndoIncidence = newUndo;
+ if ( mUndoIncidence ) {
+ mUndoIncidence->clearRelations();
+ }
+
+}
+
void Calendar::setDontDeleteIncidencesOnClose ()
{
@@ -448,5 +467,19 @@ void Calendar::removeRelations( Incidence *incidence )
// Remove this one from the orphans list
- if( mOrphanUids.remove( uid ) )
+ if( mOrphanUids.remove( uid ) ) {
+ QString r2uid = incidence->relatedToUid();
+ QPtrList<Incidence> tempList;
+ while( Incidence* i = mOrphans[ r2uid ] ) {
+ mOrphans.remove( r2uid );
+ if ( i != incidence ) tempList.append( i );
+ }
+ Incidence* inc = tempList.first();
+ while ( inc ) {
+ mOrphans.insert( r2uid, inc );
+ inc = tempList.next();
+ }
+ }
+ // LR: and another big bad bug found
+#if 0
// This incidence is located in the orphans list - it should be removed
if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
@@ -459,4 +492,5 @@ void Calendar::removeRelations( Incidence *incidence )
}
}
+#endif
}
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:
virtual void setSyncEventsReadOnly() = 0;
virtual void stopAllTodos() = 0;
+ virtual void clearUndo( Incidence * newUndo );
/**
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()
setModified( false );
}
- void CalendarLocal::clearUndo()
-{
- if ( mUndoIncidence ) {
- if ( mUndoIncidence->typeID() == eventID )
- delete ((Event*) mUndoIncidence) ;
- else if ( mUndoIncidence->typeID() == todoID )
- delete ( (Todo*) mUndoIncidence );
- else if ( mUndoIncidence->typeID() == journalID )
- delete ( (Journal*) mUndoIncidence );
- else
- delete mUndoIncidence;
- }
- mUndoIncidence = 0;
-}
+
bool CalendarLocal::addAnniversaryNoDup( Event *event )
{
@@ -341,6 +328,5 @@ bool CalendarLocal::addEvent( Event *event )
void CalendarLocal::deleteEvent( Event *event )
{
- clearUndo();
- mUndoIncidence = event;
+ clearUndo(event);
if ( mEventList.removeRef( event ) ) {
setModified( true );
@@ -396,7 +382,6 @@ void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
- clearUndo();
removeRelations( todo );
- mUndoIncidence = todo;
+ clearUndo(todo);
if ( mTodoList.removeRef( todo ) ) {
@@ -900,6 +885,5 @@ bool CalendarLocal::addJournal(Journal *journal)
void CalendarLocal::deleteJournal( Journal *journal )
{
- clearUndo();
- mUndoIncidence = journal;
+ clearUndo(journal);
if ( mJournalList.removeRef(journal) ) {
setModified( true );
@@ -980,5 +964,5 @@ void CalendarLocal::setCalendarRemove( int id )
}
- clearUndo();
+ clearUndo(0);
}
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
*/
void close();
- void clearUndo();
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)
mRelatedToUid = relatedToUid;
}
-
+void Incidence::clearRelations()
+{
+ mRelatedTo = 0;
+ mRelations.clear();
+}
QString Incidence::relatedToUid() const
{
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
virtual void cloneRelations( Incidence * );
void addRelationsToList(QPtrList<Incidence> *rel);
+ void clearRelations();
virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0;
void setReadOnly( bool );