From 9e43ebbe5867b2da957bb17c35bd357715424cba Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 09 Apr 2005 20:21:58 +0000 Subject: todo tt --- (limited to 'libkcal') diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -35,6 +35,8 @@ Todo::Todo(): Incidence() mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; + mRunning = false; + mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : Incidence(t) @@ -44,13 +46,55 @@ Todo::Todo(const Todo &t) : Incidence(t) 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); diff --git a/libkcal/todo.h b/libkcal/todo.h index a22d4b7..fe43357 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -25,13 +25,16 @@ #include "incidence.h" +#include + namespace KCal { /** This class provides a Todo in the sense of RFC2445. */ -class Todo : public Incidence + class Todo : public QObject,public Incidence { + Q_OBJECT public: Todo(); Todo(const Todo &); @@ -114,8 +117,17 @@ class Todo : public Incidence bool contains ( Todo*); void checkSetCompletedFalse(); bool setRecurDates(); - + bool isRunning() {return mRunning;} + bool hasRunningSub(); + void setRunning( bool ); + int runTime(); + QDateTime runStart () const { return mRunStart;} + public slots: + void saveRunningInfoToFile(); private: + bool mRunning; + QTimer * mRunSaveTimer; + QDateTime mRunStart; bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtDue; // due date of todo -- cgit v0.9.0.2