summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-09 20:21:58 (UTC)
committer zautrix <zautrix>2005-04-09 20:21:58 (UTC)
commit9e43ebbe5867b2da957bb17c35bd357715424cba (patch) (unidiff)
treeb506ba029b50fc46a33d35a39e6f1c768c995f22 /libkcal
parent2c39ac46121e8796e780a5321ab777f08792e5ba (diff)
downloadkdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.zip
kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.gz
kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.bz2
todo tt
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/todo.cpp44
-rw-r--r--libkcal/todo.h16
2 files changed, 58 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index a496404..7dee4cd 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -37,2 +37,4 @@ Todo::Todo(): Incidence()
37 mPercentComplete = 0; 37 mPercentComplete = 0;
38 mRunning = false;
39 mRunSaveTimer = 0;
38} 40}
@@ -46,2 +48,4 @@ Todo::Todo(const Todo &t) : Incidence(t)
46 mPercentComplete = t.mPercentComplete; 48 mPercentComplete = t.mPercentComplete;
49 mRunning = false;
50 mRunSaveTimer = 0;
47} 51}
@@ -50,5 +54,45 @@ Todo::~Todo()
50{ 54{
55 setRunning( false );
56}
57
58void Todo::setRunning( bool run )
59{
60 if ( run == mRunning )
61 return;
62 if ( !mRunSaveTimer ) {
63 mRunSaveTimer = new QTimer ( this );
64 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
65 }
66 mRunning = run;
67 if ( mRunning ) {
68 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
69 mRunStart = QDateTime::currentDateTime();
70 } else {
71 mRunSaveTimer->stop();
72 saveRunningInfoToFile();
73 }
74}
51 75
76void Todo::saveRunningInfoToFile()
77{
78 qDebug("Todo::saveRunningInfoToFile() ");
52} 79}
53 80
81int Todo::runTime()
82{
83 if ( !mRunning )
84 return 0;
85 return mRunStart.secsTo( QDateTime::currentDateTime() );
86}
87bool Todo::hasRunningSub()
88{
89 if ( mRunning )
90 return true;
91 Incidence *aTodo;
92 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
93 if ( ((Todo*)aTodo)->hasRunningSub() )
94 return true;
95 }
96 return false;
97}
54Incidence *Todo::clone() 98Incidence *Todo::clone()
diff --git a/libkcal/todo.h b/libkcal/todo.h
index a22d4b7..fe43357 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -27,2 +27,4 @@
27 27
28#include <qtimer.h>
29
28namespace KCal { 30namespace KCal {
@@ -32,4 +34,5 @@ namespace KCal {
32*/ 34*/
33class Todo : public Incidence 35 class Todo : public QObject,public Incidence
34{ 36{
37 Q_OBJECT
35 public: 38 public:
@@ -116,4 +119,13 @@ class Todo : public Incidence
116 bool setRecurDates(); 119 bool setRecurDates();
117 120 bool isRunning() {return mRunning;}
121 bool hasRunningSub();
122 void setRunning( bool );
123 int runTime();
124 QDateTime runStart () const { return mRunStart;}
125 public slots:
126 void saveRunningInfoToFile();
118 private: 127 private:
128 bool mRunning;
129 QTimer * mRunSaveTimer;
130 QDateTime mRunStart;
119 bool accept(Visitor &v) { return v.visit(this); } 131 bool accept(Visitor &v) { return v.visit(this); }