summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Unidiff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 3d2de61..7362bdf 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -243,131 +243,136 @@ void Todo::setStatus(int status)
243} 243}
244 244
245int Todo::status() const 245int Todo::status() const
246{ 246{
247 return mStatus; 247 return mStatus;
248} 248}
249 249
250QString Todo::statusStr() const 250QString Todo::statusStr() const
251{ 251{
252 switch(mStatus) { 252 switch(mStatus) {
253 case NEEDS_ACTION: 253 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 254 return QString("NEEDS ACTION");
255 break; 255 break;
256 case ACCEPTED: 256 case ACCEPTED:
257 return QString("ACCEPTED"); 257 return QString("ACCEPTED");
258 break; 258 break;
259 case SENT: 259 case SENT:
260 return QString("SENT"); 260 return QString("SENT");
261 break; 261 break;
262 case TENTATIVE: 262 case TENTATIVE:
263 return QString("TENTATIVE"); 263 return QString("TENTATIVE");
264 break; 264 break;
265 case CONFIRMED: 265 case CONFIRMED:
266 return QString("CONFIRMED"); 266 return QString("CONFIRMED");
267 break; 267 break;
268 case DECLINED: 268 case DECLINED:
269 return QString("DECLINED"); 269 return QString("DECLINED");
270 break; 270 break;
271 case COMPLETED: 271 case COMPLETED:
272 return QString("COMPLETED"); 272 return QString("COMPLETED");
273 break; 273 break;
274 case DELEGATED: 274 case DELEGATED:
275 return QString("DELEGATED"); 275 return QString("DELEGATED");
276 break; 276 break;
277 } 277 }
278 return QString(""); 278 return QString("");
279} 279}
280#endif 280#endif
281 281
282bool Todo::isCompleted() const 282bool Todo::isCompleted() const
283{ 283{
284 if (mPercentComplete == 100) return true; 284 if (mPercentComplete == 100) return true;
285 else return false; 285 else return false;
286} 286}
287 287
288void Todo::setCompleted(bool completed) 288void Todo::setCompleted(bool completed)
289{ 289{
290 if (completed) mPercentComplete = 100; 290 if (completed) mPercentComplete = 100;
291 else mPercentComplete = 0; 291 else {
292 mPercentComplete = 0;
293 mHasCompletedDate = false;
294 }
292 updated(); 295 updated();
293} 296}
294 297
295QDateTime Todo::completed() const 298QDateTime Todo::completed() const
296{ 299{
297 return mCompleted; 300 return mCompleted;
298} 301}
299 302
300QString Todo::completedStr() const 303QString Todo::completedStr() const
301{ 304{
302 return KGlobal::locale()->formatDateTime(mCompleted); 305 return KGlobal::locale()->formatDateTime(mCompleted);
303} 306}
304 307
305void Todo::setCompleted(const QDateTime &completed) 308void Todo::setCompleted(const QDateTime &completed)
306{ 309{
307 mHasCompletedDate = true; 310 mHasCompletedDate = true;
308 mPercentComplete = 100; 311 mPercentComplete = 100;
309 mCompleted = getEvenTime(completed); 312 mCompleted = getEvenTime(completed);
310 updated(); 313 updated();
311} 314}
312 315
313bool Todo::hasCompletedDate() const 316bool Todo::hasCompletedDate() const
314{ 317{
315 return mHasCompletedDate; 318 return mHasCompletedDate;
316} 319}
317 320
318int Todo::percentComplete() const 321int Todo::percentComplete() const
319{ 322{
320 return mPercentComplete; 323 return mPercentComplete;
321} 324}
322 325
323void Todo::setPercentComplete(int v) 326void Todo::setPercentComplete(int v)
324{ 327{
325 mPercentComplete = v; 328 mPercentComplete = v;
329 if ( v != 100 )
330 mHasCompletedDate = false;
326 updated(); 331 updated();
327} 332}
328QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 333QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
329{ 334{
330 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 335 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
331 *ok = false; 336 *ok = false;
332 return QDateTime (); 337 return QDateTime ();
333 } 338 }
334 QDateTime incidenceStart; 339 QDateTime incidenceStart;
335 incidenceStart = dtDue(); 340 incidenceStart = dtDue();
336 bool enabled = false; 341 bool enabled = false;
337 Alarm* alarm; 342 Alarm* alarm;
338 int off; 343 int off;
339 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 344 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
340 // if ( QDateTime::currentDateTime() > incidenceStart ){ 345 // if ( QDateTime::currentDateTime() > incidenceStart ){
341// *ok = false; 346// *ok = false;
342// return incidenceStart; 347// return incidenceStart;
343// } 348// }
344 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 349 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
345 if (alarm->enabled()) { 350 if (alarm->enabled()) {
346 if ( alarm->hasTime () ) { 351 if ( alarm->hasTime () ) {
347 if ( alarm->time() < alarmStart ) { 352 if ( alarm->time() < alarmStart ) {
348 alarmStart = alarm->time(); 353 alarmStart = alarm->time();
349 enabled = true; 354 enabled = true;
350 off = alarmStart.secsTo( incidenceStart ); 355 off = alarmStart.secsTo( incidenceStart );
351 } 356 }
352 357
353 } else { 358 } else {
354 int secs = alarm->startOffset().asSeconds(); 359 int secs = alarm->startOffset().asSeconds();
355 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 360 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
356 alarmStart = incidenceStart.addSecs( secs ); 361 alarmStart = incidenceStart.addSecs( secs );
357 enabled = true; 362 enabled = true;
358 off = -secs; 363 off = -secs;
359 } 364 }
360 } 365 }
361 } 366 }
362 } 367 }
363 if ( enabled ) { 368 if ( enabled ) {
364 if ( alarmStart > QDateTime::currentDateTime() ) { 369 if ( alarmStart > QDateTime::currentDateTime() ) {
365 *ok = true; 370 *ok = true;
366 * offset = off; 371 * offset = off;
367 return alarmStart; 372 return alarmStart;
368 } 373 }
369 } 374 }
370 *ok = false; 375 *ok = false;
371 return QDateTime (); 376 return QDateTime ();
372 377
373} 378}