-rw-r--r-- | libkcal/todo.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -34,8 +34,10 @@ Todo::Todo(): Incidence() setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; + mRunning = false; + mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : Incidence(t) { @@ -43,15 +45,57 @@ Todo::Todo(const Todo &t) : Incidence(t) mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; + mRunning = false; + mRunSaveTimer = 0; } Todo::~Todo() { + setRunning( false ); +} + +void Todo::setRunning( bool run ) +{ + if ( run == mRunning ) + return; + if ( !mRunSaveTimer ) { + mRunSaveTimer = new QTimer ( this ); + connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); + } + mRunning = run; + if ( mRunning ) { + mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min + mRunStart = QDateTime::currentDateTime(); + } else { + mRunSaveTimer->stop(); + saveRunningInfoToFile(); + } +} +void Todo::saveRunningInfoToFile() +{ + qDebug("Todo::saveRunningInfoToFile() "); } +int Todo::runTime() +{ + if ( !mRunning ) + return 0; + return mRunStart.secsTo( QDateTime::currentDateTime() ); +} +bool Todo::hasRunningSub() +{ + if ( mRunning ) + return true; + Incidence *aTodo; + for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { + if ( ((Todo*)aTodo)->hasRunningSub() ) + return true; + } + return false; +} Incidence *Todo::clone() { return new Todo(*this); } |