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) (ignore 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
@@ -22,48 +22,92 @@
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "todo.h" 25#include "todo.h"
26 26
27using namespace KCal; 27using namespace KCal;
28 28
29Todo::Todo(): Incidence() 29Todo::Todo(): Incidence()
30{ 30{
31// mStatus = TENTATIVE; 31// mStatus = TENTATIVE;
32 32
33 mHasDueDate = false; 33 mHasDueDate = false;
34 setHasStartDate( false ); 34 setHasStartDate( false );
35 mCompleted = getEvenTime(QDateTime::currentDateTime()); 35 mCompleted = getEvenTime(QDateTime::currentDateTime());
36 mHasCompletedDate = false; 36 mHasCompletedDate = false;
37 mPercentComplete = 0; 37 mPercentComplete = 0;
38 mRunning = false;
39 mRunSaveTimer = 0;
38} 40}
39 41
40Todo::Todo(const Todo &t) : Incidence(t) 42Todo::Todo(const Todo &t) : Incidence(t)
41{ 43{
42 mDtDue = t.mDtDue; 44 mDtDue = t.mDtDue;
43 mHasDueDate = t.mHasDueDate; 45 mHasDueDate = t.mHasDueDate;
44 mCompleted = t.mCompleted; 46 mCompleted = t.mCompleted;
45 mHasCompletedDate = t.mHasCompletedDate; 47 mHasCompletedDate = t.mHasCompletedDate;
46 mPercentComplete = t.mPercentComplete; 48 mPercentComplete = t.mPercentComplete;
49 mRunning = false;
50 mRunSaveTimer = 0;
47} 51}
48 52
49Todo::~Todo() 53Todo::~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()
55{ 99{
56 return new Todo(*this); 100 return new Todo(*this);
57} 101}
58 102
59bool Todo::contains ( Todo* from ) 103bool Todo::contains ( Todo* from )
60{ 104{
61 105
62 if ( !from->summary().isEmpty() ) 106 if ( !from->summary().isEmpty() )
63 if ( !summary().startsWith( from->summary() )) 107 if ( !summary().startsWith( from->summary() ))
64 return false; 108 return false;
65 if ( from->hasStartDate() ) { 109 if ( from->hasStartDate() ) {
66 if ( !hasStartDate() ) 110 if ( !hasStartDate() )
67 return false; 111 return false;
68 if ( from->dtStart() != dtStart()) 112 if ( from->dtStart() != dtStart())
69 return false; 113 return false;
diff --git a/libkcal/todo.h b/libkcal/todo.h
index a22d4b7..fe43357 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -12,39 +12,42 @@
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h>
29
28namespace KCal { 30namespace KCal {
29 31
30/** 32/**
31 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
32*/ 34*/
33class Todo : public Incidence 35 class Todo : public QObject,public Incidence
34{ 36{
37 Q_OBJECT
35 public: 38 public:
36 Todo(); 39 Todo();
37 Todo(const Todo &); 40 Todo(const Todo &);
38 ~Todo(); 41 ~Todo();
39 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
40 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
41 44
42 /** Return an exact copy of this todo. */ 45 /** Return an exact copy of this todo. */
43 Incidence *clone(); 46 Incidence *clone();
44 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; 47 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
45 48
46 /** for setting the todo's due date/time with a QDateTime. */ 49 /** for setting the todo's due date/time with a QDateTime. */
47 void setDtDue(const QDateTime &dtDue); 50 void setDtDue(const QDateTime &dtDue);
48 /** returns an event's Due date/time as a QDateTime. */ 51 /** returns an event's Due date/time as a QDateTime. */
49 QDateTime dtDue() const; 52 QDateTime dtDue() const;
50 /** returns an event's due time as a string formatted according to the 53 /** returns an event's due time as a string formatted according to the
@@ -101,34 +104,43 @@ class Todo : public Incidence
101 Set how many percent of the task are completed. Valid values are in the 104 Set how many percent of the task are completed. Valid values are in the
102 range from 0 to 100. 105 range from 0 to 100.
103 */ 106 */
104 void setPercentComplete(int); 107 void setPercentComplete(int);
105 108
106 /** return date and time when todo was completed */ 109 /** return date and time when todo was completed */
107 QDateTime completed() const; 110 QDateTime completed() const;
108 QString completedStr(bool shortF = true) const; 111 QString completedStr(bool shortF = true) const;
109 /** set date and time of completion */ 112 /** set date and time of completion */
110 void setCompleted(const QDateTime &completed); 113 void setCompleted(const QDateTime &completed);
111 114
112 /** Return true, if todo has a date associated with completion */ 115 /** Return true, if todo has a date associated with completion */
113 bool hasCompletedDate() const; 116 bool hasCompletedDate() const;
114 bool contains ( Todo*); 117 bool contains ( Todo*);
115 void checkSetCompletedFalse(); 118 void checkSetCompletedFalse();
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); }
120 132
121 QDateTime mDtDue; // due date of todo 133 QDateTime mDtDue; // due date of todo
122 134
123 bool mHasDueDate; // if todo has associated due date 135 bool mHasDueDate; // if todo has associated due date
124 136
125// int mStatus; // confirmed/delegated/tentative/etc 137// int mStatus; // confirmed/delegated/tentative/etc
126 138
127 QDateTime mCompleted; 139 QDateTime mCompleted;
128 bool mHasCompletedDate; 140 bool mHasCompletedDate;
129 141
130 int mPercentComplete; 142 int mPercentComplete;
131}; 143};
132 144
133 bool operator==( const Todo&, const Todo& ); 145 bool operator==( const Todo&, const Todo& );
134} 146}