summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
authorzautrix <zautrix>2005-07-30 08:08:47 (UTC)
committer zautrix <zautrix>2005-07-30 08:08:47 (UTC)
commit055928e26613f4ab249bd82be86890ed278372f6 (patch) (side-by-side diff)
tree0dfc4cba815a2ba0b30c71fbd74b340e2bcc8572 /libkcal/calendarlocal.cpp
parent9cbd19485635dc0edacd14403e4c63d6d469bfce (diff)
downloadkdepimpi-055928e26613f4ab249bd82be86890ed278372f6.zip
kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.gz
kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.bz2
fixxx
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 5baa7dc..e8c969f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -268,7 +268,20 @@ 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;
@@ -327,8 +340,8 @@ bool CalendarLocal::addEvent( Event *event )
void CalendarLocal::deleteEvent( Event *event )
{
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = event->clone();
+ clearUndo();
+ mUndoIncidence = event;
if ( mEventList.removeRef( event ) ) {
setModified( true );
}
@@ -382,9 +395,9 @@ bool CalendarLocal::addTodo( Todo *todo )
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 );
@@ -886,9 +899,8 @@ bool CalendarLocal::addJournal(Journal *journal)
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 );
}
@@ -967,8 +979,7 @@ void CalendarLocal::setCalendarRemove( int id )
}
}
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = 0;
+ clearUndo();
}