author | zautrix <zautrix> | 2005-07-30 08:08:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-30 08:08:47 (UTC) |
commit | 055928e26613f4ab249bd82be86890ed278372f6 (patch) (side-by-side diff) | |
tree | 0dfc4cba815a2ba0b30c71fbd74b340e2bcc8572 /libkcal | |
parent | 9cbd19485635dc0edacd14403e4c63d6d469bfce (diff) | |
download | kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.zip kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.gz kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/calendarlocal.cpp | 31 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/journal.cpp | 4 |
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 @@ -263,17 +263,30 @@ void CalendarLocal::close() mJournalList.clear(); 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; cat = i18n( "Anniversary" ); } else if( event->categoriesStr() == i18n( "Birthday" ) ) { @@ -322,18 +335,18 @@ bool CalendarLocal::addEvent( Event *event ) event->setCalID( mDefaultCalendar ); event->setCalEnabled( true ); return true; } void CalendarLocal::deleteEvent( Event *event ) { - if ( mUndoIncidence ) delete mUndoIncidence; - mUndoIncidence = event->clone(); + clearUndo(); + mUndoIncidence = event; if ( mEventList.removeRef( event ) ) { setModified( true ); } } Event *CalendarLocal::event( const QString &uid ) { @@ -377,19 +390,19 @@ bool CalendarLocal::addTodo( Todo *todo ) todo->setCalID( mDefaultCalendar ); todo->setCalEnabled( true ); 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 ); } } QPtrList<Todo> CalendarLocal::rawTodos() { @@ -881,19 +894,18 @@ bool CalendarLocal::addJournal(Journal *journal) if ( journal->calID() == 0 ) journal->setCalID( mDefaultCalendar ); 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 ) { QPtrList<Journal> el; @@ -962,18 +974,17 @@ void CalendarLocal::setCalendarRemove( int id ) Journal * ev = JournalList.first(); while ( ev ) { 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() ) if ( it->calID() == id ) it->setCalEnabled( enable ); diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a7a85c8..ae7e30c 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -64,16 +64,17 @@ class CalendarLocal : public Calendar @param fileName the name of the file */ 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. */ void removeSyncInfo( QString syncProfile); bool addAnniversaryNoDup( Event *event ); diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp index c4e4474..328db46 100644 --- a/libkcal/journal.cpp +++ b/libkcal/journal.cpp @@ -19,22 +19,22 @@ */ #include "journal.h" using namespace KCal; Journal::Journal() { - qDebug("New JJJ "); + } Journal::~Journal() { - qDebug("delete JJJ "); + } Incidence *Journal::clone() { return new Journal(*this); } |