-rw-r--r-- | libkcal/incidence.cpp | 9 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 4 | ||||
-rw-r--r-- | libkcal/todo.cpp | 51 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
6 files changed, 64 insertions, 8 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index dbc159c..0684af2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -649 +649,10 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
649 | } | 649 | } |
650 | QDateTime Incidence::dtStart() const | ||
651 | { | ||
652 | if ( doesRecur() ) { | ||
653 | if ( type() == "Todo" ) { | ||
654 | ((Todo*)this)->checkSetCompletedFalse(); | ||
655 | } | ||
656 | } | ||
657 | return mDtStart; | ||
658 | } | ||
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 38d2aaa..0ae9656 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -271,2 +271,3 @@ class Incidence : public IncidenceBase | |||
271 | QDateTime recurrenceID () const; | 271 | QDateTime recurrenceID () const; |
272 | QDateTime dtStart() const; | ||
272 | 273 | ||
@@ -276,2 +277,4 @@ protected: | |||
276 | QPtrList<Incidence> mRelations; | 277 | QPtrList<Incidence> mRelations; |
278 | QDateTime mRecurrenceID; | ||
279 | bool mHasRecurrenceID; | ||
277 | private: | 280 | private: |
@@ -281,4 +284,2 @@ protected: | |||
281 | // base components of jounal, event and todo | 284 | // base components of jounal, event and todo |
282 | QDateTime mRecurrenceID; | ||
283 | bool mHasRecurrenceID; | ||
284 | QDateTime mCreated; | 285 | QDateTime mCreated; |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 7525a4a..51f2e9d 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -181,2 +181,3 @@ void IncidenceBase::setDtStart(const QDateTime &dtStart) | |||
181 | 181 | ||
182 | |||
182 | QDateTime IncidenceBase::dtStart() const | 183 | QDateTime IncidenceBase::dtStart() const |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index f9a6558..8624786 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -76,3 +76,3 @@ class IncidenceBase : public CustomProperties | |||
76 | /** returns an event's starting date/time as a QDateTime. */ | 76 | /** returns an event's starting date/time as a QDateTime. */ |
77 | QDateTime dtStart() const; | 77 | virtual QDateTime dtStart() const; |
78 | /** returns an event's starting time as a string formatted according to the | 78 | /** returns an event's starting time as a string formatted according to the |
@@ -143,2 +143,3 @@ class IncidenceBase : public CustomProperties | |||
143 | protected: | 143 | protected: |
144 | QDateTime mDtStart; | ||
144 | bool mReadOnly; | 145 | bool mReadOnly; |
@@ -148,3 +149,2 @@ class IncidenceBase : public CustomProperties | |||
148 | // base components | 149 | // base components |
149 | QDateTime mDtStart; | ||
150 | QString mOrganizer; | 150 | QString mOrganizer; |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9c04a7e..1f54c2f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -313,4 +313,6 @@ bool Todo::isCompleted() const | |||
313 | { | 313 | { |
314 | if (mPercentComplete == 100) return true; | 314 | if (mPercentComplete == 100) { |
315 | else return false; | 315 | return true; |
316 | } | ||
317 | else return false; | ||
316 | } | 318 | } |
@@ -319,2 +321,6 @@ void Todo::setCompleted(bool completed) | |||
319 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | ||
323 | if ( !setRecurDates() ) | ||
324 | completed = false; | ||
325 | } | ||
320 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
@@ -359,5 +365,29 @@ int Todo::percentComplete() const | |||
359 | } | 365 | } |
360 | 366 | bool Todo::setRecurDates() | |
361 | void Todo::setPercentComplete(int v) | ||
362 | { | 367 | { |
368 | if ( !mHasRecurrenceID ) | ||
369 | return true; | ||
370 | int secs = mDtStart.secsTo( dtDue() ); | ||
371 | bool ok; | ||
372 | qDebug("--------------------setRecurDates() "); | ||
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | ||
375 | if ( ok ) { | ||
376 | mRecurrenceID = next; | ||
377 | mDtStart = next; | ||
378 | setDtDue( next.addSecs( secs ) ); | ||
379 | if ( QDateTime::currentDateTime() > next) | ||
380 | return false; | ||
381 | } else { | ||
382 | setHasRecurrenceID( false ); | ||
383 | recurrence()->unsetRecurs(); | ||
384 | } | ||
385 | return true; | ||
386 | } | ||
387 | void Todo::setPercentComplete(int v) | ||
388 | { | ||
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | ||
390 | if ( !setRecurDates() ) | ||
391 | v = 0; | ||
392 | } | ||
363 | mPercentComplete = v; | 393 | mPercentComplete = v; |
@@ -414 +444,14 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | |||
414 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | ||
446 | { | ||
447 | if ( !hasRecurrenceID() ) { | ||
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | ||
449 | } | ||
450 | // qDebug("Todo::checkSetCompletedFalse()"); | ||
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | ||
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
454 | setCompleted( false ); | ||
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | ||
456 | } | ||
457 | } | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 137b252..a22d4b7 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -114,2 +114,4 @@ class Todo : public Incidence | |||
114 | bool contains ( Todo*); | 114 | bool contains ( Todo*); |
115 | void checkSetCompletedFalse(); | ||
116 | bool setRecurDates(); | ||
115 | 117 | ||