summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 56c9801..55ac6d4 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -337,263 +337,267 @@ bool Incidence::recursOn(const QDate &qd) const
337{ 337{
338 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 338 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true;
339 else return false; 339 else return false;
340} 340}
341 341
342void Incidence::setExDates(const DateList &exDates) 342void Incidence::setExDates(const DateList &exDates)
343{ 343{
344 if (mReadOnly) return; 344 if (mReadOnly) return;
345 mExDates = exDates; 345 mExDates = exDates;
346 346
347 recurrence()->setRecurExDatesCount(mExDates.count()); 347 recurrence()->setRecurExDatesCount(mExDates.count());
348 348
349 updated(); 349 updated();
350} 350}
351 351
352void Incidence::addExDate(const QDate &date) 352void Incidence::addExDate(const QDate &date)
353{ 353{
354 if (mReadOnly) return; 354 if (mReadOnly) return;
355 mExDates.append(date); 355 mExDates.append(date);
356 356
357 recurrence()->setRecurExDatesCount(mExDates.count()); 357 recurrence()->setRecurExDatesCount(mExDates.count());
358 358
359 updated(); 359 updated();
360} 360}
361 361
362DateList Incidence::exDates() const 362DateList Incidence::exDates() const
363{ 363{
364 return mExDates; 364 return mExDates;
365} 365}
366 366
367bool Incidence::isException(const QDate &date) const 367bool Incidence::isException(const QDate &date) const
368{ 368{
369 DateList::ConstIterator it; 369 DateList::ConstIterator it;
370 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 370 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
371 if ( (*it) == date ) { 371 if ( (*it) == date ) {
372 return true; 372 return true;
373 } 373 }
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378 378
379void Incidence::addAttachment(Attachment *attachment) 379void Incidence::addAttachment(Attachment *attachment)
380{ 380{
381 if (mReadOnly || !attachment) return; 381 if (mReadOnly || !attachment) return;
382 mAttachments.append(attachment); 382 mAttachments.append(attachment);
383 updated(); 383 updated();
384} 384}
385 385
386void Incidence::deleteAttachment(Attachment *attachment) 386void Incidence::deleteAttachment(Attachment *attachment)
387{ 387{
388 mAttachments.removeRef(attachment); 388 mAttachments.removeRef(attachment);
389} 389}
390 390
391void Incidence::deleteAttachments(const QString& mime) 391void Incidence::deleteAttachments(const QString& mime)
392{ 392{
393 Attachment *at = mAttachments.first(); 393 Attachment *at = mAttachments.first();
394 while (at) { 394 while (at) {
395 if (at->mimeType() == mime) 395 if (at->mimeType() == mime)
396 mAttachments.remove(); 396 mAttachments.remove();
397 else 397 else
398 at = mAttachments.next(); 398 at = mAttachments.next();
399 } 399 }
400} 400}
401 401
402QPtrList<Attachment> Incidence::attachments() const 402QPtrList<Attachment> Incidence::attachments() const
403{ 403{
404 return mAttachments; 404 return mAttachments;
405} 405}
406 406
407QPtrList<Attachment> Incidence::attachments(const QString& mime) const 407QPtrList<Attachment> Incidence::attachments(const QString& mime) const
408{ 408{
409 QPtrList<Attachment> attachments; 409 QPtrList<Attachment> attachments;
410 QPtrListIterator<Attachment> it( mAttachments ); 410 QPtrListIterator<Attachment> it( mAttachments );
411 Attachment *at; 411 Attachment *at;
412 while ( (at = it.current()) ) { 412 while ( (at = it.current()) ) {
413 if (at->mimeType() == mime) 413 if (at->mimeType() == mime)
414 attachments.append(at); 414 attachments.append(at);
415 ++it; 415 ++it;
416 } 416 }
417 417
418 return attachments; 418 return attachments;
419} 419}
420 420
421void Incidence::setResources(const QStringList &resources) 421void Incidence::setResources(const QStringList &resources)
422{ 422{
423 if (mReadOnly) return; 423 if (mReadOnly) return;
424 mResources = resources; 424 mResources = resources;
425 updated(); 425 updated();
426} 426}
427 427
428QStringList Incidence::resources() const 428QStringList Incidence::resources() const
429{ 429{
430 return mResources; 430 return mResources;
431} 431}
432 432
433 433
434void Incidence::setPriority(int priority) 434void Incidence::setPriority(int priority)
435{ 435{
436 if (mReadOnly) return; 436 if (mReadOnly) return;
437 mPriority = priority; 437 mPriority = priority;
438 updated(); 438 updated();
439} 439}
440 440
441int Incidence::priority() const 441int Incidence::priority() const
442{ 442{
443 return mPriority; 443 return mPriority;
444} 444}
445 445
446void Incidence::setSecrecy(int sec) 446void Incidence::setSecrecy(int sec)
447{ 447{
448 if (mReadOnly) return; 448 if (mReadOnly) return;
449 mSecrecy = sec; 449 mSecrecy = sec;
450 updated(); 450 updated();
451} 451}
452 452
453int Incidence::secrecy() const 453int Incidence::secrecy() const
454{ 454{
455 return mSecrecy; 455 return mSecrecy;
456} 456}
457 457
458QString Incidence::secrecyStr() const 458QString Incidence::secrecyStr() const
459{ 459{
460 return secrecyName(mSecrecy); 460 return secrecyName(mSecrecy);
461} 461}
462 462
463QString Incidence::secrecyName(int secrecy) 463QString Incidence::secrecyName(int secrecy)
464{ 464{
465 switch (secrecy) { 465 switch (secrecy) {
466 case SecrecyPublic: 466 case SecrecyPublic:
467 return i18n("Public"); 467 return i18n("Public");
468 break; 468 break;
469 case SecrecyPrivate: 469 case SecrecyPrivate:
470 return i18n("Private"); 470 return i18n("Private");
471 break; 471 break;
472 case SecrecyConfidential: 472 case SecrecyConfidential:
473 return i18n("Confidential"); 473 return i18n("Confidential");
474 break; 474 break;
475 default: 475 default:
476 return i18n("Undefined"); 476 return i18n("Undefined");
477 break; 477 break;
478 } 478 }
479} 479}
480 480
481QStringList Incidence::secrecyList() 481QStringList Incidence::secrecyList()
482{ 482{
483 QStringList list; 483 QStringList list;
484 list << secrecyName(SecrecyPublic); 484 list << secrecyName(SecrecyPublic);
485 list << secrecyName(SecrecyPrivate); 485 list << secrecyName(SecrecyPrivate);
486 list << secrecyName(SecrecyConfidential); 486 list << secrecyName(SecrecyConfidential);
487 487
488 return list; 488 return list;
489} 489}
490 490
491 491
492QPtrList<Alarm> Incidence::alarms() const 492QPtrList<Alarm> Incidence::alarms() const
493{ 493{
494 return mAlarms; 494 return mAlarms;
495} 495}
496 496
497Alarm* Incidence::newAlarm() 497Alarm* Incidence::newAlarm()
498{ 498{
499 Alarm* alarm = new Alarm(this); 499 Alarm* alarm = new Alarm(this);
500 mAlarms.append(alarm); 500 mAlarms.append(alarm);
501// updated(); 501// updated();
502 return alarm; 502 return alarm;
503} 503}
504 504
505void Incidence::addAlarm(Alarm *alarm) 505void Incidence::addAlarm(Alarm *alarm)
506{ 506{
507 mAlarms.append(alarm); 507 mAlarms.append(alarm);
508 updated(); 508 updated();
509} 509}
510 510
511void Incidence::removeAlarm(Alarm *alarm) 511void Incidence::removeAlarm(Alarm *alarm)
512{ 512{
513 mAlarms.removeRef(alarm); 513 mAlarms.removeRef(alarm);
514 updated(); 514 updated();
515} 515}
516 516
517void Incidence::clearAlarms() 517void Incidence::clearAlarms()
518{ 518{
519 mAlarms.clear(); 519 mAlarms.clear();
520 updated(); 520 updated();
521} 521}
522 522
523bool Incidence::isAlarmEnabled() const 523bool Incidence::isAlarmEnabled() const
524{ 524{
525 Alarm* alarm; 525 Alarm* alarm;
526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 526 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
527 if (alarm->enabled()) 527 if (alarm->enabled())
528 return true; 528 return true;
529 } 529 }
530 return false; 530 return false;
531} 531}
532 532
533Recurrence *Incidence::recurrence() const 533Recurrence *Incidence::recurrence() const
534{ 534{
535 return mRecurrence; 535 return mRecurrence;
536} 536}
537void Incidence::setRecurrence( Recurrence * r) 537void Incidence::setRecurrence( Recurrence * r)
538{ 538{
539 delete mRecurrence; 539 delete mRecurrence;
540 mRecurrence = r; 540 mRecurrence = r;
541} 541}
542 542
543void Incidence::setLocation(const QString &location) 543void Incidence::setLocation(const QString &location)
544{ 544{
545 if (mReadOnly) return; 545 if (mReadOnly) return;
546 mLocation = location; 546 mLocation = location;
547 updated(); 547 updated();
548} 548}
549 549
550QString Incidence::location() const 550QString Incidence::location() const
551{ 551{
552 return mLocation; 552 return mLocation;
553} 553}
554 554
555ushort Incidence::doesRecur() const 555ushort Incidence::doesRecur() const
556{ 556{
557 if ( mRecurrence ) return mRecurrence->doesRecur(); 557 if ( mRecurrence ) return mRecurrence->doesRecur();
558 else return Recurrence::rNone; 558 else return Recurrence::rNone;
559} 559}
560 560
561QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 561QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
562{ 562{
563 QDateTime incidenceStart = dt; 563 QDateTime incidenceStart = dt;
564 *ok = false; 564 *ok = false;
565 if ( doesRecur() ) { 565 if ( doesRecur() ) {
566 bool last; 566 bool last;
567 recurrence()->getPreviousDateTime( incidenceStart , &last ); 567 recurrence()->getPreviousDateTime( incidenceStart , &last );
568 int count = 0; 568 int count = 0;
569 if ( !last ) { 569 if ( !last ) {
570 while ( !last ) { 570 while ( !last ) {
571 ++count; 571 ++count;
572 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 572 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
573 if ( recursOn( incidenceStart.date() ) ) { 573 if ( recursOn( incidenceStart.date() ) ) {
574 last = true; // exit while llop 574 last = true; // exit while llop
575 } else { 575 } else {
576 if ( last ) { // no alarm on last recurrence 576 if ( last ) { // no alarm on last recurrence
577 return QDateTime (); 577 return QDateTime ();
578 } 578 }
579 int year = incidenceStart.date().year(); 579 int year = incidenceStart.date().year();
580 // workaround for bug in recurrence 580 // workaround for bug in recurrence
581 if ( count == 100 || year < 1980 || year > 5000 ) { 581 if ( count == 100 || year < 1980 || year > 5000 ) {
582 return QDateTime (); 582 return QDateTime ();
583 } 583 }
584 incidenceStart = incidenceStart.addSecs( 1 ); 584 incidenceStart = incidenceStart.addSecs( 1 );
585 } 585 }
586 } 586 }
587 } else { 587 } else {
588 return QDateTime (); 588 return QDateTime ();
589 } 589 }
590 } else { 590 } else {
591 if ( hasStartDate () ) { 591 if ( hasStartDate () ) {
592 incidenceStart = dtStart(); 592 incidenceStart = dtStart();
593 593 }
594 } 594 if ( type() =="Todo" ) {
595 if ( ((Todo*)this)->hasDueDate() )
596 incidenceStart = ((Todo*)this)->dtDue();
597
598 }
595 } 599 }
596 if ( incidenceStart > dt ) 600 if ( incidenceStart > dt )
597 *ok = true; 601 *ok = true;
598 return incidenceStart; 602 return incidenceStart;
599} 603}