author | zautrix <zautrix> | 2005-04-15 07:31:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-15 07:31:29 (UTC) |
commit | 6a16de9a18235d2ddd771c97a4bb4512b43d181a (patch) (side-by-side diff) | |
tree | 3fec37074addd6afc6eebb191d57a1d5ef5127ab | |
parent | 7e87a287a0860882af27e26288bc9cc553dd3a0b (diff) | |
download | kdepimpi-6a16de9a18235d2ddd771c97a4bb4512b43d181a.zip kdepimpi-6a16de9a18235d2ddd771c97a4bb4512b43d181a.tar.gz kdepimpi-6a16de9a18235d2ddd771c97a4bb4512b43d181a.tar.bz2 |
fix
-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 @@ -22,16 +22,17 @@ #include <kglobalsettings.h> #include <klocale.h> #include <kdebug.h> #include <qregexp.h> +#include <qfileinfo.h> #include "calendarlocal.h" #include "icalformat.h" #include "todo.h" using namespace KCal; -Todo::Todo(): Incidence() +Todo::Todo(): QObject(), Incidence() { // mStatus = TENTATIVE; mHasDueDate = false; @@ -42,9 +43,9 @@ Todo::Todo(): Incidence() mRunning = false; mRunSaveTimer = 0; } -Todo::Todo(const Todo &t) : Incidence(t) +Todo::Todo(const Todo &t) : QObject(),Incidence(t) { mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; @@ -80,10 +81,12 @@ 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-"; file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); @@ -102,10 +105,37 @@ void Todo::saveRunningInfoToFile() cal.addIncidence( to ); 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() { if ( !mRunning ) diff --git a/libkcal/todo.h b/libkcal/todo.h index fe43357..ec1ffda 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -123,8 +123,9 @@ namespace KCal { int runTime(); QDateTime runStart () const { return mRunStart;} public slots: void saveRunningInfoToFile(); + void saveParents(); private: bool mRunning; QTimer * mRunSaveTimer; QDateTime mRunStart; |