summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp31
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/journal.cpp4
3 files changed, 24 insertions, 12 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 5baa7dc..e8c969f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -265,13 +265,26 @@ void CalendarLocal::close()
mEventList.setAutoDelete( false );
mTodoList.setAutoDelete( false );
mJournalList.setAutoDelete( false );
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;
bool isBirthday = true;
if( event->categoriesStr() == i18n( "Anniversary" ) ) {
isBirthday = false;
@@ -324,14 +337,14 @@ bool CalendarLocal::addEvent( Event *event )
return true;
}
void CalendarLocal::deleteEvent( Event *event )
{
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = event->clone();
+ clearUndo();
+ mUndoIncidence = event;
if ( mEventList.removeRef( event ) ) {
setModified( true );
}
}
@@ -379,15 +392,15 @@ bool CalendarLocal::addTodo( Todo *todo )
return true;
}
void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
- if ( mUndoIncidence ) delete mUndoIncidence;
+ clearUndo();
removeRelations( todo );
- mUndoIncidence = todo->clone();
+ mUndoIncidence = todo;
if ( mTodoList.removeRef( todo ) ) {
setModified( true );
}
}
@@ -883,15 +896,14 @@ bool CalendarLocal::addJournal(Journal *journal)
journal->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteJournal( Journal *journal )
{
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = journal->clone();
- mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
+ clearUndo();
+ mUndoIncidence = journal;
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
}
QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
@@ -964,14 +976,13 @@ void CalendarLocal::setCalendarRemove( int id )
if ( ev->calID() == id )
deleteJournal( ev );
ev = JournalList.next();
}
}
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = 0;
+ clearUndo();
}
void CalendarLocal::setCalendarEnabled( int id, bool enable )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a7a85c8..ae7e30c 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -66,12 +66,13 @@ class CalendarLocal : public Calendar
bool save( const QString &fileName, CalFormat *format = 0 );
/**
Clears out the current calendar, freeing all used memory etc. etc.
*/
void close();
+ void clearUndo();
void save() {}
/**
Add Event to calendar.
*/
diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp
index c4e4474..328db46 100644
--- a/libkcal/journal.cpp
+++ b/libkcal/journal.cpp
@@ -21,18 +21,18 @@
#include "journal.h"
using namespace KCal;
Journal::Journal()
{
- qDebug("New JJJ ");
+
}
Journal::~Journal()
{
- qDebug("delete JJJ ");
+
}
Incidence *Journal::clone()
{
return new Journal(*this);
}