summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-09-25 01:04:17 (UTC)
committer zautrix <zautrix>2005-09-25 01:04:17 (UTC)
commitbd991f0a33d85385735ed4911b794b8740e4d296 (patch) (unidiff)
treef69fdacca2283e2602619e24bcbc30b46998d298
parentbada5cffd8f1b5f4f3719299e3615d7d06a1f0dc (diff)
downloadkdepimpi-bd991f0a33d85385735ed4911b794b8740e4d296.zip
kdepimpi-bd991f0a33d85385735ed4911b794b8740e4d296.tar.gz
kdepimpi-bd991f0a33d85385735ed4911b794b8740e4d296.tar.bz2
todo timer fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp31
-rw-r--r--libkcal/todo.h4
2 files changed, 33 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 48d37d5..de07496 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,627 +1,654 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
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 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32#define SAVETIMER_TIMEOUT_SECONDS 300
33//#define SAVETIMER_TIMEOUT_SECONDS 8
34#define SAVETIMER_TIMEOUT_RETRY_SECONDS 5
35
32using namespace KCal; 36using namespace KCal;
33 37
34Todo::Todo(): QObject(), Incidence() 38Todo::Todo(): QObject(), Incidence()
35{ 39{
36// mStatus = TENTATIVE; 40// mStatus = TENTATIVE;
37 41
38 mHasDueDate = false; 42 mHasDueDate = false;
39 setHasStartDate( false ); 43 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 44 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 45 mHasCompletedDate = false;
42 mPercentComplete = 0; 46 mPercentComplete = 0;
43 mRunning = false; 47 mRunning = false;
44 mRunSaveTimer = 0; 48 mRunSaveTimer = 0;
45 setFloats( true ); 49 setFloats( true );
50 mCurrentTimerDelay = 0;
46} 51}
47 52
48Todo::Todo(const Todo &t) : QObject(),Incidence(t) 53Todo::Todo(const Todo &t) : QObject(),Incidence(t)
49{ 54{
50 mDtDue = t.mDtDue; 55 mDtDue = t.mDtDue;
51 mHasDueDate = t.mHasDueDate; 56 mHasDueDate = t.mHasDueDate;
52 mCompleted = t.mCompleted; 57 mCompleted = t.mCompleted;
53 mHasCompletedDate = t.mHasCompletedDate; 58 mHasCompletedDate = t.mHasCompletedDate;
54 mPercentComplete = t.mPercentComplete; 59 mPercentComplete = t.mPercentComplete;
55 mRunning = false; 60 mRunning = false;
56 mRunSaveTimer = 0; 61 mRunSaveTimer = 0;
62 mCurrentTimerDelay = 0;
57} 63}
58 64
59Todo::~Todo() 65Todo::~Todo()
60{ 66{
61 setRunning( false ); 67 setRunning( false );
62 //qDebug("Todo::~Todo() "); 68 //qDebug("Todo::~Todo() ");
63} 69}
64 70
65void Todo::setRunningFalse( QString s ) 71void Todo::setRunningFalse( QString s )
66{ 72{
67 if ( ! mRunning ) 73 if ( ! mRunning )
68 return; 74 return;
69 mRunning = false; 75 mRunning = false;
70 if ( mRunSaveTimer ) 76 if ( mRunSaveTimer )
71 mRunSaveTimer->stop(); 77 mRunSaveTimer->stop();
72 saveRunningInfoToFile( s ); 78 saveRunningInfoToFile( s );
73} 79}
74void Todo::stopRunning() 80void Todo::stopRunning()
75{ 81{
76 if ( !mRunning ) 82 if ( !mRunning )
77 return; 83 return;
78 if ( mRunSaveTimer ) 84 if ( mRunSaveTimer )
79 mRunSaveTimer->stop(); 85 mRunSaveTimer->stop();
80 mRunning = false; 86 mRunning = false;
81} 87}
82void Todo::setRunning( bool run ) 88void Todo::setRunning( bool run )
83{ 89{
84 if ( run == mRunning ) 90 if ( run == mRunning )
85 return; 91 return;
86 //qDebug("Todo::setRunning %d ", run); 92 //qDebug("Todo::setRunning %d ", run);
87 if ( !mRunSaveTimer ) { 93 if ( !mRunSaveTimer ) {
88 mRunSaveTimer = new QTimer ( this ); 94 mRunSaveTimer = new QTimer ( this );
89 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 95 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) );
90 } 96 }
91 mRunning = run; 97 mRunning = run;
98 mRunLastSave = QDateTime::currentDateTime();
92 if ( mRunning ) { 99 if ( mRunning ) {
93 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 100 mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min
94 mRunStart = QDateTime::currentDateTime(); 101 mRunStart = QDateTime::currentDateTime();
102 mRunLastSave = QDateTime::currentDateTime();
103 mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS;
95 } else { 104 } else {
96 mRunSaveTimer->stop(); 105 mRunSaveTimer->stop();
97 saveRunningInfoToFile(); 106 saveRunningInfoToFile();
98 } 107 }
99} 108}
100void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) 109void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
101{ 110{
102 if ( !mRunning) return; 111 if ( !mRunning) return;
103 mRunning = false; 112 mRunning = false;
104 mRunStart = start; 113 mRunStart = start;
105 mRunEnd = end; 114 mRunEnd = end;
106 saveRunningInfoToFile( comment ); 115 saveRunningInfoToFile( comment );
107} 116}
117void Todo::timerSlotSaveRunningInfoToFile()
118{
119 mRunEnd = QDateTime::currentDateTime();
120 int secsTo = mRunLastSave.secsTo( mRunEnd );
121 if( secsTo == 8 ) ++secsTo;
122 qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay );
123 if ( secsTo > mCurrentTimerDelay ) {
124 qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS );
125 mRunSaveTimer->start( SAVETIMER_TIMEOUT_RETRY_SECONDS * 1000 );
126 mRunLastSave = QDateTime::currentDateTime();
127 mCurrentTimerDelay = SAVETIMER_TIMEOUT_RETRY_SECONDS;
128 return;
129 }
130 mRunSaveTimer->start( SAVETIMER_TIMEOUT_SECONDS * 1000 ); // 5 min
131 mRunLastSave = QDateTime::currentDateTime();
132 mCurrentTimerDelay = SAVETIMER_TIMEOUT_SECONDS;
133 saveRunningInfoToFile( QString::null );
134}
108void Todo::saveRunningInfoToFile() 135void Todo::saveRunningInfoToFile()
109{ 136{
110 mRunEnd = QDateTime::currentDateTime(); 137 mRunEnd = QDateTime::currentDateTime();
111 saveRunningInfoToFile( QString::null ); 138 saveRunningInfoToFile( QString::null );
112} 139}
113void Todo::saveRunningInfoToFile( QString comment ) 140void Todo::saveRunningInfoToFile( QString comment )
114{ 141{
115 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 142 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
116 if ( mRunStart.secsTo ( mRunEnd) < 15 ) { 143 if ( mRunStart.secsTo ( mRunEnd) < 15 ) {
117 qDebug("Running time < 15 seconds. Skipped. "); 144 qDebug("Running time < 15 seconds. Skipped. ");
118 return; 145 return;
119 } 146 }
120 QString dir = KGlobalSettings::timeTrackerDir(); 147 QString dir = KGlobalSettings::timeTrackerDir();
121 //qDebug("%s ", dir.latin1()); 148 //qDebug("%s ", dir.latin1());
122 QString file = "%1%2%3-%4%5%6-"; 149 QString file = "%1%2%3-%4%5%6-";
123 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 ); 150 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 );
124 file.replace ( QRegExp (" "), "0" ); 151 file.replace ( QRegExp (" "), "0" );
125 file += uid(); 152 file += uid();
126 //qDebug("File %s ",file.latin1() ); 153 //qDebug("File %s ",file.latin1() );
127 CalendarLocal cal; 154 CalendarLocal cal;
128 cal.setLocalTime(); 155 cal.setLocalTime();
129 Todo * to = (Todo*) clone(); 156 Todo * to = (Todo*) clone();
130 to->setFloats( false ); 157 to->setFloats( false );
131 to->setDtStart( mRunStart ); 158 to->setDtStart( mRunStart );
132 to->setHasStartDate( true ); 159 to->setHasStartDate( true );
133 to->setDtDue( mRunEnd ); 160 to->setDtDue( mRunEnd );
134 to->setHasDueDate( true ); 161 to->setHasDueDate( true );
135 to->setUid( file ); 162 to->setUid( file );
136 if ( !comment.isEmpty() ) { 163 if ( !comment.isEmpty() ) {
137 QString des = to->description(); 164 QString des = to->description();
138 if ( des.isEmpty () ) 165 if ( des.isEmpty () )
139 to->setDescription( "TT-Note: " + comment ); 166 to->setDescription( "TT-Note: " + comment );
140 else 167 else
141 to->setDescription( "TT-Note: " + comment +"\n" + des ); 168 to->setDescription( "TT-Note: " + comment +"\n" + des );
142 } 169 }
143 cal.addIncidence( to ); 170 cal.addIncidence( to );
144 ICalFormat format( false ); 171 ICalFormat format( false );
145 file = dir +"/" +file +".ics"; 172 file = dir +"/" +file +".ics";
146 format.save( &cal, file ); 173 format.save( &cal, file );
147 saveParents(); 174 saveParents();
148 175
149} 176}
150void Todo::saveParents() 177void Todo::saveParents()
151{ 178{
152 if (!relatedTo() ) 179 if (!relatedTo() )
153 return; 180 return;
154 Incidence * inc = relatedTo(); 181 Incidence * inc = relatedTo();
155 if ( inc->typeID() != todoID ) 182 if ( inc->typeID() != todoID )
156 return; 183 return;
157 Todo* to = (Todo*)inc; 184 Todo* to = (Todo*)inc;
158 bool saveTodo = false; 185 bool saveTodo = false;
159 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 186 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
160 QFileInfo fi ( file ); 187 QFileInfo fi ( file );
161 if ( fi.exists() ) { 188 if ( fi.exists() ) {
162 if ( fi.lastModified () < to->lastModified ()) 189 if ( fi.lastModified () < to->lastModified ())
163 saveTodo = true; 190 saveTodo = true;
164 } else { 191 } else {
165 saveTodo = true; 192 saveTodo = true;
166 } 193 }
167 if ( saveTodo ) { 194 if ( saveTodo ) {
168 CalendarLocal cal; 195 CalendarLocal cal;
169 cal.setLocalTime(); 196 cal.setLocalTime();
170 Todo * par = (Todo *) to->clone(); 197 Todo * par = (Todo *) to->clone();
171 cal.addIncidence( par ); 198 cal.addIncidence( par );
172 ICalFormat format( false ); 199 ICalFormat format( false );
173 format.save( &cal, file ); 200 format.save( &cal, file );
174 } 201 }
175 to->saveParents(); 202 to->saveParents();
176} 203}
177 204
178int Todo::runTime() 205int Todo::runTime()
179{ 206{
180 if ( !mRunning ) 207 if ( !mRunning )
181 return 0; 208 return 0;
182 return mRunStart.secsTo( QDateTime::currentDateTime() ); 209 return mRunStart.secsTo( QDateTime::currentDateTime() );
183} 210}
184bool Todo::hasRunningSub() 211bool Todo::hasRunningSub()
185{ 212{
186 if ( mRunning ) 213 if ( mRunning )
187 return true; 214 return true;
188 Incidence *aTodo; 215 Incidence *aTodo;
189 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 216 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
190 if ( ((Todo*)aTodo)->hasRunningSub() ) 217 if ( ((Todo*)aTodo)->hasRunningSub() )
191 return true; 218 return true;
192 } 219 }
193 return false; 220 return false;
194} 221}
195Incidence *Todo::clone() 222Incidence *Todo::clone()
196{ 223{
197 return new Todo(*this); 224 return new Todo(*this);
198} 225}
199 226
200bool Todo::contains ( Todo* from ) 227bool Todo::contains ( Todo* from )
201{ 228{
202 229
203 if ( !from->summary().isEmpty() ) 230 if ( !from->summary().isEmpty() )
204 if ( !summary().startsWith( from->summary() )) 231 if ( !summary().startsWith( from->summary() ))
205 return false; 232 return false;
206 if ( from->hasStartDate() ) { 233 if ( from->hasStartDate() ) {
207 if ( !hasStartDate() ) 234 if ( !hasStartDate() )
208 return false; 235 return false;
209 if ( from->dtStart() != dtStart()) 236 if ( from->dtStart() != dtStart())
210 return false; 237 return false;
211 } 238 }
212 if ( from->hasDueDate() ){ 239 if ( from->hasDueDate() ){
213 if ( !hasDueDate() ) 240 if ( !hasDueDate() )
214 return false; 241 return false;
215 if ( from->dtDue() != dtDue()) 242 if ( from->dtDue() != dtDue())
216 return false; 243 return false;
217 } 244 }
218 if ( !from->location().isEmpty() ) 245 if ( !from->location().isEmpty() )
219 if ( !location().startsWith( from->location() ) ) 246 if ( !location().startsWith( from->location() ) )
220 return false; 247 return false;
221 if ( !from->description().isEmpty() ) 248 if ( !from->description().isEmpty() )
222 if ( !description().startsWith( from->description() )) 249 if ( !description().startsWith( from->description() ))
223 return false; 250 return false;
224 if ( from->alarms().count() ) { 251 if ( from->alarms().count() ) {
225 Alarm *a = from->alarms().first(); 252 Alarm *a = from->alarms().first();
226 if ( a->enabled() ){ 253 if ( a->enabled() ){
227 if ( !alarms().count() ) 254 if ( !alarms().count() )
228 return false; 255 return false;
229 Alarm *b = alarms().first(); 256 Alarm *b = alarms().first();
230 if( ! b->enabled() ) 257 if( ! b->enabled() )
231 return false; 258 return false;
232 if ( ! (a->offset() == b->offset() )) 259 if ( ! (a->offset() == b->offset() ))
233 return false; 260 return false;
234 } 261 }
235 } 262 }
236 263
237 QStringList cat = categories(); 264 QStringList cat = categories();
238 QStringList catFrom = from->categories(); 265 QStringList catFrom = from->categories();
239 QString nCat; 266 QString nCat;
240 unsigned int iii; 267 unsigned int iii;
241 for ( iii = 0; iii < catFrom.count();++iii ) { 268 for ( iii = 0; iii < catFrom.count();++iii ) {
242 nCat = catFrom[iii]; 269 nCat = catFrom[iii];
243 if ( !nCat.isEmpty() ) 270 if ( !nCat.isEmpty() )
244 if ( !cat.contains( nCat )) { 271 if ( !cat.contains( nCat )) {
245 return false; 272 return false;
246 } 273 }
247 } 274 }
248 if ( from->isCompleted() ) { 275 if ( from->isCompleted() ) {
249 if ( !isCompleted() ) 276 if ( !isCompleted() )
250 return false; 277 return false;
251 } 278 }
252 if( priority() != from->priority() ) 279 if( priority() != from->priority() )
253 return false; 280 return false;
254 281
255 282
256 return true; 283 return true;
257 284
258} 285}
259bool KCal::operator==( const Todo& t1, const Todo& t2 ) 286bool KCal::operator==( const Todo& t1, const Todo& t2 )
260{ 287{
261 288
262 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 289 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
263 if ( ! ret ) 290 if ( ! ret )
264 return false; 291 return false;
265 if ( t1.hasDueDate() == t2.hasDueDate() ) { 292 if ( t1.hasDueDate() == t2.hasDueDate() ) {
266 if ( t1.hasDueDate() ) { 293 if ( t1.hasDueDate() ) {
267 if ( t1.doesFloat() == t2.doesFloat() ) { 294 if ( t1.doesFloat() == t2.doesFloat() ) {
268 if ( t1.doesFloat() ) { 295 if ( t1.doesFloat() ) {
269 if ( t1.dtDue().date() != t2.dtDue().date() ) 296 if ( t1.dtDue().date() != t2.dtDue().date() )
270 return false; 297 return false;
271 } else 298 } else
272 if ( t1.dtDue() != t2.dtDue() ) 299 if ( t1.dtDue() != t2.dtDue() )
273 return false; 300 return false;
274 } else 301 } else
275 return false;// float != 302 return false;// float !=
276 } 303 }
277 304
278 } else 305 } else
279 return false; 306 return false;
280 if ( t1.percentComplete() != t2.percentComplete() ) 307 if ( t1.percentComplete() != t2.percentComplete() )
281 return false; 308 return false;
282 if ( t1.isCompleted() ) { 309 if ( t1.isCompleted() ) {
283 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 310 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
284 if ( t1.hasCompletedDate() ) { 311 if ( t1.hasCompletedDate() ) {
285 if ( t1.completed() != t2.completed() ) 312 if ( t1.completed() != t2.completed() )
286 return false; 313 return false;
287 } 314 }
288 315
289 } else 316 } else
290 return false; 317 return false;
291 } 318 }
292 return true; 319 return true;
293 320
294} 321}
295 322
296void Todo::setDtDue(const QDateTime &dtDue) 323void Todo::setDtDue(const QDateTime &dtDue)
297{ 324{
298 //int diffsecs = mDtDue.secsTo(dtDue); 325 //int diffsecs = mDtDue.secsTo(dtDue);
299 326
300 /*if (mReadOnly) return; 327 /*if (mReadOnly) return;
301 const QPtrList<Alarm>& alarms = alarms(); 328 const QPtrList<Alarm>& alarms = alarms();
302 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 329 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
303 if (alarm->enabled()) { 330 if (alarm->enabled()) {
304 alarm->setTime(alarm->time().addSecs(diffsecs)); 331 alarm->setTime(alarm->time().addSecs(diffsecs));
305 } 332 }
306 }*/ 333 }*/
307 mDtDue = getEvenTime(dtDue); 334 mDtDue = getEvenTime(dtDue);
308 335
309 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 336 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
310 337
311 /*const QPtrList<Alarm>& alarms = alarms(); 338 /*const QPtrList<Alarm>& alarms = alarms();
312 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 339 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
313 alarm->setAlarmStart(mDtDue);*/ 340 alarm->setAlarmStart(mDtDue);*/
314 updated(); 341 updated();
315} 342}
316 343
317QDateTime Todo::dtDue() const 344QDateTime Todo::dtDue() const
318{ 345{
319 return mDtDue; 346 return mDtDue;
320} 347}
321 348
322QString Todo::dtDueTimeStr() const 349QString Todo::dtDueTimeStr() const
323{ 350{
324 return KGlobal::locale()->formatTime(mDtDue.time()); 351 return KGlobal::locale()->formatTime(mDtDue.time());
325} 352}
326 353
327QString Todo::dtDueDateStr(bool shortfmt) const 354QString Todo::dtDueDateStr(bool shortfmt) const
328{ 355{
329 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 356 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
330} 357}
331 358
332QString Todo::dtDueStr(bool shortfmt) const 359QString Todo::dtDueStr(bool shortfmt) const
333{ 360{
334 if ( doesFloat() ) 361 if ( doesFloat() )
335 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 362 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
336 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 363 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
337} 364}
338// retval 0 : no found 365// retval 0 : no found
339// 1 : due for date found 366// 1 : due for date found
340// 2 : overdue for date found 367// 2 : overdue for date found
341int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) 368int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
342{ 369{
343 int retval = 0; 370 int retval = 0;
344 if ( isCompleted() ) 371 if ( isCompleted() )
345 return 0; 372 return 0;
346 if ( hasDueDate() ) { 373 if ( hasDueDate() ) {
347 if ( dtDue().date() < date ) 374 if ( dtDue().date() < date )
348 return 2; 375 return 2;
349 // we do not return, because we may find an overdue sub todo 376 // we do not return, because we may find an overdue sub todo
350 if ( dtDue().date() == date ) 377 if ( dtDue().date() == date )
351 retval = 1; 378 retval = 1;
352 } 379 }
353 if ( checkSubtodos ) { 380 if ( checkSubtodos ) {
354 Incidence *aTodo; 381 Incidence *aTodo;
355 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 382 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
356 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); 383 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
357 if ( ret == 2 ) 384 if ( ret == 2 )
358 return 2; 385 return 2;
359 if ( ret == 1) 386 if ( ret == 1)
360 retval = 1; 387 retval = 1;
361 } 388 }
362 } 389 }
363 return retval; 390 return retval;
364} 391}
365int Todo::hasDueSubTodo( bool checkSubtodos ) //= true 392int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
366{ 393{
367 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); 394 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
368} 395}
369bool Todo::hasDueDate() const 396bool Todo::hasDueDate() const
370{ 397{
371 return mHasDueDate; 398 return mHasDueDate;
372} 399}
373 400
374void Todo::setHasDueDate(bool f) 401void Todo::setHasDueDate(bool f)
375{ 402{
376 if (mReadOnly) return; 403 if (mReadOnly) return;
377 mHasDueDate = f; 404 mHasDueDate = f;
378 updated(); 405 updated();
379} 406}
380 407
381 408
382#if 0 409#if 0
383void Todo::setStatus(const QString &statStr) 410void Todo::setStatus(const QString &statStr)
384{ 411{
385 if (mReadOnly) return; 412 if (mReadOnly) return;
386 QString ss(statStr.upper()); 413 QString ss(statStr.upper());
387 414
388 if (ss == "X-ACTION") 415 if (ss == "X-ACTION")
389 mStatus = NEEDS_ACTION; 416 mStatus = NEEDS_ACTION;
390 else if (ss == "NEEDS ACTION") 417 else if (ss == "NEEDS ACTION")
391 mStatus = NEEDS_ACTION; 418 mStatus = NEEDS_ACTION;
392 else if (ss == "ACCEPTED") 419 else if (ss == "ACCEPTED")
393 mStatus = ACCEPTED; 420 mStatus = ACCEPTED;
394 else if (ss == "SENT") 421 else if (ss == "SENT")
395 mStatus = SENT; 422 mStatus = SENT;
396 else if (ss == "TENTATIVE") 423 else if (ss == "TENTATIVE")
397 mStatus = TENTATIVE; 424 mStatus = TENTATIVE;
398 else if (ss == "CONFIRMED") 425 else if (ss == "CONFIRMED")
399 mStatus = CONFIRMED; 426 mStatus = CONFIRMED;
400 else if (ss == "DECLINED") 427 else if (ss == "DECLINED")
401 mStatus = DECLINED; 428 mStatus = DECLINED;
402 else if (ss == "COMPLETED") 429 else if (ss == "COMPLETED")
403 mStatus = COMPLETED; 430 mStatus = COMPLETED;
404 else if (ss == "DELEGATED") 431 else if (ss == "DELEGATED")
405 mStatus = DELEGATED; 432 mStatus = DELEGATED;
406 433
407 updated(); 434 updated();
408} 435}
409 436
410void Todo::setStatus(int status) 437void Todo::setStatus(int status)
411{ 438{
412 if (mReadOnly) return; 439 if (mReadOnly) return;
413 mStatus = status; 440 mStatus = status;
414 updated(); 441 updated();
415} 442}
416 443
417int Todo::status() const 444int Todo::status() const
418{ 445{
419 return mStatus; 446 return mStatus;
420} 447}
421 448
422QString Todo::statusStr() const 449QString Todo::statusStr() const
423{ 450{
424 switch(mStatus) { 451 switch(mStatus) {
425 case NEEDS_ACTION: 452 case NEEDS_ACTION:
426 return QString("NEEDS ACTION"); 453 return QString("NEEDS ACTION");
427 break; 454 break;
428 case ACCEPTED: 455 case ACCEPTED:
429 return QString("ACCEPTED"); 456 return QString("ACCEPTED");
430 break; 457 break;
431 case SENT: 458 case SENT:
432 return QString("SENT"); 459 return QString("SENT");
433 break; 460 break;
434 case TENTATIVE: 461 case TENTATIVE:
435 return QString("TENTATIVE"); 462 return QString("TENTATIVE");
436 break; 463 break;
437 case CONFIRMED: 464 case CONFIRMED:
438 return QString("CONFIRMED"); 465 return QString("CONFIRMED");
439 break; 466 break;
440 case DECLINED: 467 case DECLINED:
441 return QString("DECLINED"); 468 return QString("DECLINED");
442 break; 469 break;
443 case COMPLETED: 470 case COMPLETED:
444 return QString("COMPLETED"); 471 return QString("COMPLETED");
445 break; 472 break;
446 case DELEGATED: 473 case DELEGATED:
447 return QString("DELEGATED"); 474 return QString("DELEGATED");
448 break; 475 break;
449 } 476 }
450 return QString(""); 477 return QString("");
451} 478}
452#endif 479#endif
453 480
454bool Todo::isCompleted() const 481bool Todo::isCompleted() const
455{ 482{
456 if (mPercentComplete == 100) { 483 if (mPercentComplete == 100) {
457 return true; 484 return true;
458 } 485 }
459 else return false; 486 else return false;
460} 487}
461 488
462void Todo::setCompleted(bool completed) 489void Todo::setCompleted(bool completed)
463{ 490{
464 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 491 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
465 if ( !setRecurDates() ) 492 if ( !setRecurDates() )
466 completed = false; 493 completed = false;
467 } 494 }
468 if (completed) mPercentComplete = 100; 495 if (completed) mPercentComplete = 100;
469 else { 496 else {
470 mPercentComplete = 0; 497 mPercentComplete = 0;
471 mHasCompletedDate = false; 498 mHasCompletedDate = false;
472 } 499 }
473 updated(); 500 updated();
474} 501}
475 502
476QDateTime Todo::completed() const 503QDateTime Todo::completed() const
477{ 504{
478 return mCompleted; 505 return mCompleted;
479} 506}
480 507
481QString Todo::completedStr( bool shortF ) const 508QString Todo::completedStr( bool shortF ) const
482{ 509{
483 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 510 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
484} 511}
485 512
486void Todo::setCompleted(const QDateTime &completed) 513void Todo::setCompleted(const QDateTime &completed)
487{ 514{
488 //qDebug("Todo::setCompleted "); 515 //qDebug("Todo::setCompleted ");
489 if ( mHasCompletedDate ) { 516 if ( mHasCompletedDate ) {
490 // qDebug("has completed data - return "); 517 // qDebug("has completed data - return ");
491 return; 518 return;
492 } 519 }
493 mHasCompletedDate = true; 520 mHasCompletedDate = true;
494 mPercentComplete = 100; 521 mPercentComplete = 100;
495 mCompleted = getEvenTime(completed); 522 mCompleted = getEvenTime(completed);
496 updated(); 523 updated();
497} 524}
498 525
499bool Todo::hasCompletedDate() const 526bool Todo::hasCompletedDate() const
500{ 527{
501 return mHasCompletedDate; 528 return mHasCompletedDate;
502} 529}
503 530
504int Todo::percentComplete() const 531int Todo::percentComplete() const
505{ 532{
506 return mPercentComplete; 533 return mPercentComplete;
507} 534}
508bool Todo::setRecurDates() 535bool Todo::setRecurDates()
509{ 536{
510 if ( !mHasRecurrenceID ) 537 if ( !mHasRecurrenceID )
511 return true; 538 return true;
512 int secs = mDtStart.secsTo( dtDue() ); 539 int secs = mDtStart.secsTo( dtDue() );
513 bool ok; 540 bool ok;
514 qDebug("T:setRecurDates() "); 541 qDebug("T:setRecurDates() ");
515 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 542 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
516 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 543 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
517 if ( ok ) { 544 if ( ok ) {
518 mRecurrenceID = next; 545 mRecurrenceID = next;
519 mDtStart = next; 546 mDtStart = next;
520 setDtDue( next.addSecs( secs ) ); 547 setDtDue( next.addSecs( secs ) );
521 if ( QDateTime::currentDateTime() > next) 548 if ( QDateTime::currentDateTime() > next)
522 return false; 549 return false;
523 } else { 550 } else {
524 setHasRecurrenceID( false ); 551 setHasRecurrenceID( false );
525 recurrence()->unsetRecurs(); 552 recurrence()->unsetRecurs();
526 } 553 }
527 return true; 554 return true;
528} 555}
529void Todo::setPercentComplete(int v) 556void Todo::setPercentComplete(int v)
530{ 557{
531 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 558 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
532 if ( !setRecurDates() ) 559 if ( !setRecurDates() )
533 v = 0; 560 v = 0;
534 } 561 }
535 mPercentComplete = v; 562 mPercentComplete = v;
536 if ( v != 100 ) 563 if ( v != 100 )
537 mHasCompletedDate = false; 564 mHasCompletedDate = false;
538 updated(); 565 updated();
539} 566}
540QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 567QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
541{ 568{
542 *ok = false; 569 *ok = false;
543 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { 570 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) {
544 return QDateTime (); 571 return QDateTime ();
545 } 572 }
546 // if the recurring todo is set to complete and requested time < start time of todo 573 // if the recurring todo is set to complete and requested time < start time of todo
547 // we want to get the alarm. 574 // we want to get the alarm.
548 bool iscompleted = isCompleted(); 575 bool iscompleted = isCompleted();
549 if ( iscompleted && doesRecur() ) { 576 if ( iscompleted && doesRecur() ) {
550 Todo * to = (Todo*) this; 577 Todo * to = (Todo*) this;
551 to->checkSetCompletedFalse(); 578 to->checkSetCompletedFalse();
552 iscompleted = isCompleted(); 579 iscompleted = isCompleted();
553 if ( hasStartDate() && start_dt < dtStart() ){ 580 if ( hasStartDate() && start_dt < dtStart() ){
554 iscompleted = false; 581 iscompleted = false;
555 } 582 }
556 } 583 }
557 if ( iscompleted ) { 584 if ( iscompleted ) {
558 return QDateTime (); 585 return QDateTime ();
559 } 586 }
560 QDateTime incidenceStart; 587 QDateTime incidenceStart;
561 incidenceStart = dtDue(); 588 incidenceStart = dtDue();
562 bool enabled = false; 589 bool enabled = false;
563 Alarm* alarm; 590 Alarm* alarm;
564 int off = 0; 591 int off = 0;
565 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 592 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
566 // if ( QDateTime::currentDateTime() > incidenceStart ){ 593 // if ( QDateTime::currentDateTime() > incidenceStart ){
567// *ok = false; 594// *ok = false;
568// return incidenceStart; 595// return incidenceStart;
569// } 596// }
570 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 597 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
571 if (alarm->enabled()) { 598 if (alarm->enabled()) {
572 if ( alarm->hasTime () ) { 599 if ( alarm->hasTime () ) {
573 if ( alarm->time() < alarmStart ) { 600 if ( alarm->time() < alarmStart ) {
574 alarmStart = alarm->time(); 601 alarmStart = alarm->time();
575 enabled = true; 602 enabled = true;
576 off = alarmStart.secsTo( incidenceStart ); 603 off = alarmStart.secsTo( incidenceStart );
577 } 604 }
578 605
579 } else { 606 } else {
580 int secs = alarm->startOffset().asSeconds(); 607 int secs = alarm->startOffset().asSeconds();
581 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 608 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
582 alarmStart = incidenceStart.addSecs( secs ); 609 alarmStart = incidenceStart.addSecs( secs );
583 enabled = true; 610 enabled = true;
584 off = -secs; 611 off = -secs;
585 } 612 }
586 } 613 }
587 } 614 }
588 } 615 }
589 if ( enabled ) { 616 if ( enabled ) {
590 if ( alarmStart > start_dt ) { 617 if ( alarmStart > start_dt ) {
591 *ok = true; 618 *ok = true;
592 * offset = off; 619 * offset = off;
593 return alarmStart; 620 return alarmStart;
594 } 621 }
595 } 622 }
596 *ok = false; 623 *ok = false;
597 return QDateTime (); 624 return QDateTime ();
598 625
599} 626}
600 627
601void Todo::checkSetCompletedFalse() 628void Todo::checkSetCompletedFalse()
602{ 629{
603 if ( !mHasRecurrenceID ) { 630 if ( !mHasRecurrenceID ) {
604 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 631 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
605 return; 632 return;
606 } 633 }
607 // qDebug("Todo::checkSetCompletedFalse()"); 634 // qDebug("Todo::checkSetCompletedFalse()");
608 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 635 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
609 if ( mPercentComplete == 100 ) { 636 if ( mPercentComplete == 100 ) {
610 QDateTime dt = QDateTime::currentDateTime(); 637 QDateTime dt = QDateTime::currentDateTime();
611 if ( dt > mDtStart && dt > mRecurrenceID ) { 638 if ( dt > mDtStart && dt > mRecurrenceID ) {
612 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 639 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
613 setCompleted( false ); 640 setCompleted( false );
614 qDebug("Todo::checkSetCompletedFalse "); 641 qDebug("Todo::checkSetCompletedFalse ");
615 } 642 }
616 } 643 }
617} 644}
618QString Todo::durationText() 645QString Todo::durationText()
619{ 646{
620 if ( mHasDueDate && hasStartDate() ) { 647 if ( mHasDueDate && hasStartDate() ) {
621 int sec = dtStart().secsTo( dtDue() ); 648 int sec = dtStart().secsTo( dtDue() );
622 if ( doesFloat() ) 649 if ( doesFloat() )
623 sec += 86400; 650 sec += 86400;
624 return durationText4Time( sec ); 651 return durationText4Time( sec );
625 } 652 }
626 return "---"; 653 return "---";
627} 654}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 7feb32e..e6b8a21 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,156 +1,160 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
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> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; } 44 IncTypeID typeID() const { return todoID; }
45 45
46 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
47 Incidence *clone(); 47 Incidence *clone();
48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
49 49
50 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
51 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
52 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
53 QDateTime dtDue() const; 53 QDateTime dtDue() const;
54 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
55 users locale settings */ 55 users locale settings */
56 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
57 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
58 users locale settings */ 58 users locale settings */
59 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
60 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
61 to the users locale settings */ 61 to the users locale settings */
62 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
63 63
64 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
65 bool hasDueDate() const; 65 bool hasDueDate() const;
66 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
67 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
68 68
69 /* 69 /*
70 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
71 - overdue, or 71 - overdue, or
72 - due today. 72 - due today.
73 It returns 0 for nothing found, 73 It returns 0 for nothing found,
74 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
75 2 for found a overdue todo 75 2 for found a overdue todo
76 */ 76 */
77 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
78 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
80 80
81 81
82 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
83 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
84 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
85// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
86 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
87 * above for possible values. */ 87 * above for possible values. */
88// void setStatus(int); 88// void setStatus(int);
89 /** return the event's status. */ 89 /** return the event's status. */
90// int status() const; 90// int status() const;
91 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
92// QString statusStr() const; 92// QString statusStr() const;
93 93
94 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
95 bool isCompleted() const; 95 bool isCompleted() const;
96 /** set completed state of this todo */ 96 /** set completed state of this todo */
97 void setCompleted(bool); 97 void setCompleted(bool);
98 98
99 /** 99 /**
100 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
101 between 0 and 100. 101 between 0 and 100.
102 */ 102 */
103 int percentComplete() const; 103 int percentComplete() const;
104 /** 104 /**
105 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
106 range from 0 to 100. 106 range from 0 to 100.
107 */ 107 */
108 void setPercentComplete(int); 108 void setPercentComplete(int);
109 109
110 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
111 QDateTime completed() const; 111 QDateTime completed() const;
112 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
113 /** set date and time of completion */ 113 /** set date and time of completion */
114 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
115 115
116 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
117 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
118 bool contains ( Todo*); 118 bool contains ( Todo*);
119 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
120 bool setRecurDates(); 120 bool setRecurDates();
121 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
122 bool hasRunningSub(); 122 bool hasRunningSub();
123 void setRunning( bool ); 123 void setRunning( bool );
124 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
125 void stopRunning(); 125 void stopRunning();
126 int runTime(); 126 int runTime();
127 QDateTime runStart () const { return mRunStart;} 127 QDateTime runStart () const { return mRunStart;}
128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end ); 128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
129 public slots: 129 public slots:
130 void saveRunningInfoToFile( QString st ); 130 void saveRunningInfoToFile( QString st );
131 void saveRunningInfoToFile( ); 131 void saveRunningInfoToFile( );
132 void saveParents(); 132 void saveParents();
133 QString durationText(); 133 QString durationText();
134 private slots:
135 void timerSlotSaveRunningInfoToFile( );
134 private: 136 private:
137 int mCurrentTimerDelay;
135 bool mRunning; 138 bool mRunning;
136 QTimer * mRunSaveTimer; 139 QTimer * mRunSaveTimer;
137 QDateTime mRunStart; 140 QDateTime mRunStart;
141 QDateTime mRunLastSave;
138 QDateTime mRunEnd; 142 QDateTime mRunEnd;
139 bool accept(Visitor &v) { return v.visit(this); } 143 bool accept(Visitor &v) { return v.visit(this); }
140 144
141 QDateTime mDtDue; // due date of todo 145 QDateTime mDtDue; // due date of todo
142 146
143 bool mHasDueDate; // if todo has associated due date 147 bool mHasDueDate; // if todo has associated due date
144 148
145// int mStatus; // confirmed/delegated/tentative/etc 149// int mStatus; // confirmed/delegated/tentative/etc
146 150
147 QDateTime mCompleted; 151 QDateTime mCompleted;
148 bool mHasCompletedDate; 152 bool mHasCompletedDate;
149 153
150 int mPercentComplete; 154 int mPercentComplete;
151}; 155};
152 156
153 bool operator==( const Todo&, const Todo& ); 157 bool operator==( const Todo&, const Todo& );
154} 158}
155 159
156#endif 160#endif