-rw-r--r-- | libkcal/todo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 1f54c2f..39d16b6 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -308,150 +308,150 @@ QString Todo::statusStr() const | |||
308 | return QString(""); | 308 | return QString(""); |
309 | } | 309 | } |
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
313 | { | 313 | { |
314 | if (mPercentComplete == 100) { | 314 | if (mPercentComplete == 100) { |
315 | return true; | 315 | return true; |
316 | } | 316 | } |
317 | else return false; | 317 | else return false; |
318 | } | 318 | } |
319 | 319 | ||
320 | void Todo::setCompleted(bool completed) | 320 | void Todo::setCompleted(bool completed) |
321 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
323 | if ( !setRecurDates() ) | 323 | if ( !setRecurDates() ) |
324 | completed = false; | 324 | completed = false; |
325 | } | 325 | } |
326 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
327 | else { | 327 | else { |
328 | mPercentComplete = 0; | 328 | mPercentComplete = 0; |
329 | mHasCompletedDate = false; | 329 | mHasCompletedDate = false; |
330 | } | 330 | } |
331 | updated(); | 331 | updated(); |
332 | } | 332 | } |
333 | 333 | ||
334 | QDateTime Todo::completed() const | 334 | QDateTime Todo::completed() const |
335 | { | 335 | { |
336 | return mCompleted; | 336 | return mCompleted; |
337 | } | 337 | } |
338 | 338 | ||
339 | QString Todo::completedStr( bool shortF ) const | 339 | QString Todo::completedStr( bool shortF ) const |
340 | { | 340 | { |
341 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 341 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
342 | } | 342 | } |
343 | 343 | ||
344 | void Todo::setCompleted(const QDateTime &completed) | 344 | void Todo::setCompleted(const QDateTime &completed) |
345 | { | 345 | { |
346 | //qDebug("Todo::setCompleted "); | 346 | //qDebug("Todo::setCompleted "); |
347 | if ( mHasCompletedDate ) { | 347 | if ( mHasCompletedDate ) { |
348 | // qDebug("has completed data - return "); | 348 | // qDebug("has completed data - return "); |
349 | return; | 349 | return; |
350 | } | 350 | } |
351 | mHasCompletedDate = true; | 351 | mHasCompletedDate = true; |
352 | mPercentComplete = 100; | 352 | mPercentComplete = 100; |
353 | mCompleted = getEvenTime(completed); | 353 | mCompleted = getEvenTime(completed); |
354 | updated(); | 354 | updated(); |
355 | } | 355 | } |
356 | 356 | ||
357 | bool Todo::hasCompletedDate() const | 357 | bool Todo::hasCompletedDate() const |
358 | { | 358 | { |
359 | return mHasCompletedDate; | 359 | return mHasCompletedDate; |
360 | } | 360 | } |
361 | 361 | ||
362 | int Todo::percentComplete() const | 362 | int Todo::percentComplete() const |
363 | { | 363 | { |
364 | return mPercentComplete; | 364 | return mPercentComplete; |
365 | } | 365 | } |
366 | bool Todo::setRecurDates() | 366 | bool Todo::setRecurDates() |
367 | { | 367 | { |
368 | if ( !mHasRecurrenceID ) | 368 | if ( !mHasRecurrenceID ) |
369 | return true; | 369 | return true; |
370 | int secs = mDtStart.secsTo( dtDue() ); | 370 | int secs = mDtStart.secsTo( dtDue() ); |
371 | bool ok; | 371 | bool ok; |
372 | qDebug("--------------------setRecurDates() "); | 372 | qDebug("T:setRecurDates() "); |
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | 374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); |
375 | if ( ok ) { | 375 | if ( ok ) { |
376 | mRecurrenceID = next; | 376 | mRecurrenceID = next; |
377 | mDtStart = next; | 377 | mDtStart = next; |
378 | setDtDue( next.addSecs( secs ) ); | 378 | setDtDue( next.addSecs( secs ) ); |
379 | if ( QDateTime::currentDateTime() > next) | 379 | if ( QDateTime::currentDateTime() > next) |
380 | return false; | 380 | return false; |
381 | } else { | 381 | } else { |
382 | setHasRecurrenceID( false ); | 382 | setHasRecurrenceID( false ); |
383 | recurrence()->unsetRecurs(); | 383 | recurrence()->unsetRecurs(); |
384 | } | 384 | } |
385 | return true; | 385 | return true; |
386 | } | 386 | } |
387 | void Todo::setPercentComplete(int v) | 387 | void Todo::setPercentComplete(int v) |
388 | { | 388 | { |
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
390 | if ( !setRecurDates() ) | 390 | if ( !setRecurDates() ) |
391 | v = 0; | 391 | v = 0; |
392 | } | 392 | } |
393 | mPercentComplete = v; | 393 | mPercentComplete = v; |
394 | if ( v != 100 ) | 394 | if ( v != 100 ) |
395 | mHasCompletedDate = false; | 395 | mHasCompletedDate = false; |
396 | updated(); | 396 | updated(); |
397 | } | 397 | } |
398 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 398 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
399 | { | 399 | { |
400 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 400 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
401 | *ok = false; | 401 | *ok = false; |
402 | return QDateTime (); | 402 | return QDateTime (); |
403 | } | 403 | } |
404 | QDateTime incidenceStart; | 404 | QDateTime incidenceStart; |
405 | incidenceStart = dtDue(); | 405 | incidenceStart = dtDue(); |
406 | bool enabled = false; | 406 | bool enabled = false; |
407 | Alarm* alarm; | 407 | Alarm* alarm; |
408 | int off = 0; | 408 | int off = 0; |
409 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 409 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
410 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 410 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
411 | // *ok = false; | 411 | // *ok = false; |
412 | // return incidenceStart; | 412 | // return incidenceStart; |
413 | // } | 413 | // } |
414 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 414 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
415 | if (alarm->enabled()) { | 415 | if (alarm->enabled()) { |
416 | if ( alarm->hasTime () ) { | 416 | if ( alarm->hasTime () ) { |
417 | if ( alarm->time() < alarmStart ) { | 417 | if ( alarm->time() < alarmStart ) { |
418 | alarmStart = alarm->time(); | 418 | alarmStart = alarm->time(); |
419 | enabled = true; | 419 | enabled = true; |
420 | off = alarmStart.secsTo( incidenceStart ); | 420 | off = alarmStart.secsTo( incidenceStart ); |
421 | } | 421 | } |
422 | 422 | ||
423 | } else { | 423 | } else { |
424 | int secs = alarm->startOffset().asSeconds(); | 424 | int secs = alarm->startOffset().asSeconds(); |
425 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 425 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
426 | alarmStart = incidenceStart.addSecs( secs ); | 426 | alarmStart = incidenceStart.addSecs( secs ); |
427 | enabled = true; | 427 | enabled = true; |
428 | off = -secs; | 428 | off = -secs; |
429 | } | 429 | } |
430 | } | 430 | } |
431 | } | 431 | } |
432 | } | 432 | } |
433 | if ( enabled ) { | 433 | if ( enabled ) { |
434 | if ( alarmStart > QDateTime::currentDateTime() ) { | 434 | if ( alarmStart > QDateTime::currentDateTime() ) { |
435 | *ok = true; | 435 | *ok = true; |
436 | * offset = off; | 436 | * offset = off; |
437 | return alarmStart; | 437 | return alarmStart; |
438 | } | 438 | } |
439 | } | 439 | } |
440 | *ok = false; | 440 | *ok = false; |
441 | return QDateTime (); | 441 | return QDateTime (); |
442 | 442 | ||
443 | } | 443 | } |
444 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | 445 | void Todo::checkSetCompletedFalse() |
446 | { | 446 | { |
447 | if ( !hasRecurrenceID() ) { | 447 | if ( !hasRecurrenceID() ) { |
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
449 | } | 449 | } |
450 | // qDebug("Todo::checkSetCompletedFalse()"); | 450 | // qDebug("Todo::checkSetCompletedFalse()"); |
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | 452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { |
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
454 | setCompleted( false ); | 454 | setCompleted( false ); |
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | 455 | qDebug("Todo::checkSetCompletedFalse "); |
456 | } | 456 | } |
457 | } | 457 | } |