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) (side-by-side diff)
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()
Calendar::~Calendar()
{
delete mDefaultFilter;
- if ( mUndoIncidence )
- delete 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 ()
{
mDeleteIncidencesOnClose = false;
@@ -447,7 +466,21 @@ void Calendar::removeRelations( Incidence *incidence )
incidence->relatedTo()->removeRelation( 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() ) ) ) {
// Removing wasn't that easy
@@ -458,6 +491,7 @@ void Calendar::removeRelations( Incidence *incidence )
}
}
}
+#endif
}
void 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:
virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
virtual void setSyncEventsReadOnly() = 0;
virtual void stopAllTodos() = 0;
+ virtual void clearUndo( Incidence * newUndo );
/**
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()
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 )
{
QString cat;
@@ -340,8 +327,7 @@ bool CalendarLocal::addEvent( Event *event )
void CalendarLocal::deleteEvent( Event *event )
{
- clearUndo();
- mUndoIncidence = event;
+ clearUndo(event);
if ( mEventList.removeRef( event ) ) {
setModified( true );
}
@@ -395,9 +381,8 @@ bool CalendarLocal::addTodo( Todo *todo )
void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
- clearUndo();
removeRelations( todo );
- mUndoIncidence = todo;
+ clearUndo(todo);
if ( mTodoList.removeRef( todo ) ) {
setModified( true );
@@ -899,8 +884,7 @@ bool CalendarLocal::addJournal(Journal *journal)
void CalendarLocal::deleteJournal( Journal *journal )
{
- clearUndo();
- mUndoIncidence = journal;
+ clearUndo(journal);
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
@@ -979,7 +963,7 @@ 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
@@ -69,7 +69,6 @@ class CalendarLocal : public Calendar
Clears out the current calendar, freeing all used memory etc. etc.
*/
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
@@ -491,7 +491,11 @@ void Incidence::setRelatedToUid(const QString &relatedToUid)
if (mReadOnly) return;
mRelatedToUid = relatedToUid;
}
-
+void Incidence::clearRelations()
+{
+ mRelatedTo = 0;
+ mRelations.clear();
+}
QString Incidence::relatedToUid() const
{
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
virtual Incidence *clone() = 0;
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 );