-rw-r--r-- | libkcal/calendar.cpp | 11 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 9 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
5 files changed, 35 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 52daaaa..88351eb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -54,3 +54,3 @@ void Calendar::init() mNewObserver = false; - + mUndoIncidence = 0; mModified = false; @@ -111,2 +111,4 @@ Calendar::~Calendar() delete mDefaultFilter; + if ( mUndoIncidence ) + delete mUndoIncidence; } @@ -118,2 +120,9 @@ const QString &Calendar::getOwner() const +bool Calendar::undoDeleteIncidence() +{ + if (!mUndoIncidence) + return false; + addIncidence(mUndoIncidence); + mUndoIncidence = 0; +} void Calendar::setOwner(const QString &os) diff --git a/libkcal/calendar.h b/libkcal/calendar.h index b7d6a1f..2f2c3aa 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -67,2 +67,4 @@ public: virtual ~Calendar(); + Incidence * undoIncidence() { return mUndoIncidence; }; + bool undoDeleteIncidence(); void deleteIncidence(Incidence *in); @@ -324,2 +326,3 @@ public: Incidence *mNextAlarmIncidence; + Incidence *mUndoIncidence; diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3f46d53..12294c0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -154,4 +154,4 @@ void CalendarLocal::deleteEvent( Event *event ) { - - + if ( mUndoIncidence ) delete mUndoIncidence; + mUndoIncidence = event->clone(); if ( mEventList.removeRef( event ) ) { @@ -203,2 +203,4 @@ void CalendarLocal::deleteTodo( Todo *todo ) // Handle orphaned children + if ( mUndoIncidence ) delete mUndoIncidence; + mUndoIncidence = todo->clone(); removeRelations( todo ); @@ -689,2 +691,5 @@ void CalendarLocal::deleteJournal( Journal *journal ) { + if ( mUndoIncidence ) delete mUndoIncidence; + mUndoIncidence = journal->clone(); + mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); if ( mJournalList.removeRef(journal) ) { diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 5a9ef0e..28402ae 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -175,2 +175,16 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) +Incidence* Incidence::recreateCloneException( QDate d ) +{ + Incidence* newInc = clone(); + newInc->recreate(); + if ( doesRecur() ) { + addExDate( d ); + newInc->recurrence()->unsetRecurs(); + int len = dtStart().secsTo( ((Event*)this)->dtEnd()); + QTime tim = dtStart().time(); + newInc->setDtStart( QDateTime(d, tim) ); + ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); + } + return newInc; +} diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 7dc6f10..1807bc4 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -124,2 +124,3 @@ class Incidence : public IncidenceBase void recreate(); + Incidence* recreateCloneException(QDate); |