-rw-r--r-- | libkcal/todo.cpp | 36 | ||||
-rw-r--r-- | libkcal/todo.h | 1 |
2 files changed, 34 insertions, 3 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 90e7eb9..b89abce 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -25,2 +25,3 @@ #include <qregexp.h> +#include <qfileinfo.h> @@ -32,3 +33,3 @@ using namespace KCal; -Todo::Todo(): Incidence() +Todo::Todo(): QObject(), Incidence() { @@ -45,3 +46,3 @@ Todo::Todo(): Incidence() -Todo::Todo(const Todo &t) : Incidence(t) +Todo::Todo(const Todo &t) : QObject(),Incidence(t) { @@ -83,4 +84,6 @@ void Todo::saveRunningInfoToFile() //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); - if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) + if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { + qDebug("Running time < 30 seconds. Skipped. "); return; + } QString dir = KGlobalSettings::timeTrackerDir(); @@ -105,4 +108,31 @@ void Todo::saveRunningInfoToFile() format.save( &cal, file ); + saveParents(); } +void Todo::saveParents() +{ + if (!relatedTo() ) + return; + Incidence * inc = relatedTo(); + if ( inc->type() != "Todo" ) + return; + Todo* to = (Todo*)inc; + bool saveTodo = false; + QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; + QFileInfo fi ( file ); + if ( fi.exists() ) { + if ( fi.lastModified () < to->lastModified ()) + saveTodo = true; + } else { + saveTodo = true; + } + if ( saveTodo ) { + CalendarLocal cal; + cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); + Todo * par = (Todo *) to->clone(); + cal.addIncidence( par ); + ICalFormat format; + format.save( &cal, file ); + } +} diff --git a/libkcal/todo.h b/libkcal/todo.h index fe43357..ec1ffda 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -126,2 +126,3 @@ namespace KCal { void saveRunningInfoToFile(); + void saveParents(); private: |