From 6a16de9a18235d2ddd771c97a4bb4512b43d181a Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 15 Apr 2005 07:31:29 +0000 Subject: fix --- (limited to 'libkcal/todo.cpp') diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 90e7eb9..b89abce 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "calendarlocal.h" #include "icalformat.h" @@ -30,7 +31,7 @@ using namespace KCal; -Todo::Todo(): Incidence() +Todo::Todo(): QObject(), Incidence() { // mStatus = TENTATIVE; @@ -43,7 +44,7 @@ Todo::Todo(): Incidence() mRunSaveTimer = 0; } -Todo::Todo(const Todo &t) : Incidence(t) +Todo::Todo(const Todo &t) : QObject(),Incidence(t) { mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; @@ -81,8 +82,10 @@ void Todo::setRunning( bool run ) 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(); //qDebug("%s ", dir.latin1()); QString file = "%1%2%3-%4%5%6-"; @@ -103,8 +106,35 @@ void Todo::saveRunningInfoToFile() ICalFormat format; file = dir +"/" +file +".ics"; 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 ); + } +} int Todo::runTime() { -- cgit v0.9.0.2