summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-01-31 16:29:05 (UTC)
committer zautrix <zautrix>2005-01-31 16:29:05 (UTC)
commitec037c4616342c1b3976c55db98b775f48e0d455 (patch) (unidiff)
tree9d568c8f6ad6005f822c12644596b7a553837c7f /libkcal
parent5d52c81be9b43887c13f8534a04164d3b44b821f (diff)
downloadkdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.zip
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.gz
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.bz2
fix
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp1
-rw-r--r--libkcal/incidence.cpp3
2 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0eba6a9..e75154b 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -542,96 +542,97 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
542 Event *event; 542 Event *event;
543 for( event = mEventList.first(); event; event = mEventList.next() ) { 543 for( event = mEventList.first(); event; event = mEventList.next() ) {
544 if ( event->doesRecur() ) { 544 if ( event->doesRecur() ) {
545 if ( event->isMultiDay() ) { 545 if ( event->isMultiDay() ) {
546 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 546 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
547 int i; 547 int i;
548 for ( i = 0; i <= extraDays; i++ ) { 548 for ( i = 0; i <= extraDays; i++ ) {
549 if ( event->recursOn( qd.addDays( -i ) ) ) { 549 if ( event->recursOn( qd.addDays( -i ) ) ) {
550 eventList.append( event ); 550 eventList.append( event );
551 break; 551 break;
552 } 552 }
553 } 553 }
554 } else { 554 } else {
555 if ( event->recursOn( qd ) ) 555 if ( event->recursOn( qd ) )
556 eventList.append( event ); 556 eventList.append( event );
557 } 557 }
558 } else { 558 } else {
559 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 559 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
560 eventList.append( event ); 560 eventList.append( event );
561 } 561 }
562 } 562 }
563 } 563 }
564 564
565 if ( !sorted ) { 565 if ( !sorted ) {
566 return eventList; 566 return eventList;
567 } 567 }
568 568
569 // kdDebug(5800) << "Sorting events for date\n" << endl; 569 // kdDebug(5800) << "Sorting events for date\n" << endl;
570 // now, we have to sort it based on dtStart.time() 570 // now, we have to sort it based on dtStart.time()
571 QPtrList<Event> eventListSorted; 571 QPtrList<Event> eventListSorted;
572 Event *sortEvent; 572 Event *sortEvent;
573 for ( event = eventList.first(); event; event = eventList.next() ) { 573 for ( event = eventList.first(); event; event = eventList.next() ) {
574 sortEvent = eventListSorted.first(); 574 sortEvent = eventListSorted.first();
575 int i = 0; 575 int i = 0;
576 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 576 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
577 { 577 {
578 i++; 578 i++;
579 sortEvent = eventListSorted.next(); 579 sortEvent = eventListSorted.next();
580 } 580 }
581 eventListSorted.insert( i, event ); 581 eventListSorted.insert( i, event );
582 } 582 }
583 return eventListSorted; 583 return eventListSorted;
584} 584}
585 585
586 586
587QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 587QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
588 bool inclusive ) 588 bool inclusive )
589{ 589{
590 qDebug("CalendarLocal::rawEvents called ");
590 Event *event = 0; 591 Event *event = 0;
591 592
592 QPtrList<Event> eventList; 593 QPtrList<Event> eventList;
593 594
594 // Get non-recurring events 595 // Get non-recurring events
595 for( event = mEventList.first(); event; event = mEventList.next() ) { 596 for( event = mEventList.first(); event; event = mEventList.next() ) {
596 if ( event->doesRecur() ) { 597 if ( event->doesRecur() ) {
597 QDate rStart = event->dtStart().date(); 598 QDate rStart = event->dtStart().date();
598 bool found = false; 599 bool found = false;
599 if ( inclusive ) { 600 if ( inclusive ) {
600 if ( rStart >= start && rStart <= end ) { 601 if ( rStart >= start && rStart <= end ) {
601 // Start date of event is in range. Now check for end date. 602 // Start date of event is in range. Now check for end date.
602 // if duration is negative, event recurs forever, so do not include it. 603 // if duration is negative, event recurs forever, so do not include it.
603 if ( event->recurrence()->duration() == 0 ) { // End date set 604 if ( event->recurrence()->duration() == 0 ) { // End date set
604 QDate rEnd = event->recurrence()->endDate(); 605 QDate rEnd = event->recurrence()->endDate();
605 if ( rEnd >= start && rEnd <= end ) { // End date within range 606 if ( rEnd >= start && rEnd <= end ) { // End date within range
606 found = true; 607 found = true;
607 } 608 }
608 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 609 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
609 // TODO: Calculate end date from duration. Should be done in Event 610 // TODO: Calculate end date from duration. Should be done in Event
610 // For now exclude all events with a duration. 611 // For now exclude all events with a duration.
611 } 612 }
612 } 613 }
613 } else { 614 } else {
614 bool founOne; 615 bool founOne;
615 QDate next = event->getNextOccurence( start, &founOne ).date(); 616 QDate next = event->getNextOccurence( start, &founOne ).date();
616 if ( founOne ) { 617 if ( founOne ) {
617 if ( next <= end ) { 618 if ( next <= end ) {
618 found = true; 619 found = true;
619 } 620 }
620 } 621 }
621 622
622 /* 623 /*
623 // crap !!! 624 // crap !!!
624 if ( rStart <= end ) { // Start date not after range 625 if ( rStart <= end ) { // Start date not after range
625 if ( rStart >= start ) { // Start date within range 626 if ( rStart >= start ) { // Start date within range
626 found = true; 627 found = true;
627 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 628 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
628 found = true; 629 found = true;
629 } else if ( event->recurrence()->duration() == 0 ) { // End date set 630 } else if ( event->recurrence()->duration() == 0 ) { // End date set
630 QDate rEnd = event->recurrence()->endDate(); 631 QDate rEnd = event->recurrence()->endDate();
631 if ( rEnd >= start && rEnd <= end ) { // End date within range 632 if ( rEnd >= start && rEnd <= end ) { // End date within range
632 found = true; 633 found = true;
633 } 634 }
634 } else { // Duration set 635 } else { // Duration set
635 // TODO: Calculate end date from duration. Should be done in Event 636 // TODO: Calculate end date from duration. Should be done in Event
636 // For now include all events with a duration. 637 // For now include all events with a duration.
637 found = true; 638 found = true;
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 28402ae..f9e1e9e 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -547,71 +547,70 @@ bool Incidence::isAlarmEnabled() const
547Recurrence *Incidence::recurrence() const 547Recurrence *Incidence::recurrence() const
548{ 548{
549 return mRecurrence; 549 return mRecurrence;
550} 550}
551void Incidence::setRecurrence( Recurrence * r) 551void Incidence::setRecurrence( Recurrence * r)
552{ 552{
553 delete mRecurrence; 553 delete mRecurrence;
554 mRecurrence = r; 554 mRecurrence = r;
555} 555}
556 556
557void Incidence::setLocation(const QString &location) 557void Incidence::setLocation(const QString &location)
558{ 558{
559 if (mReadOnly) return; 559 if (mReadOnly) return;
560 mLocation = location; 560 mLocation = location;
561 updated(); 561 updated();
562} 562}
563 563
564QString Incidence::location() const 564QString Incidence::location() const
565{ 565{
566 return mLocation; 566 return mLocation;
567} 567}
568 568
569ushort Incidence::doesRecur() const 569ushort Incidence::doesRecur() const
570{ 570{
571 if ( mRecurrence ) return mRecurrence->doesRecur(); 571 if ( mRecurrence ) return mRecurrence->doesRecur();
572 else return Recurrence::rNone; 572 else return Recurrence::rNone;
573} 573}
574 574
575QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 575QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
576{ 576{
577 QDateTime incidenceStart = dt; 577 QDateTime incidenceStart = dt;
578 *ok = false; 578 *ok = false;
579 if ( doesRecur() ) { 579 if ( doesRecur() ) {
580 bool last; 580 bool last;
581 recurrence()->getPreviousDateTime( incidenceStart , &last ); 581 recurrence()->getPreviousDateTime( incidenceStart , &last );
582 int count = 0; 582 int count = 0;
583 if ( !last ) { 583 if ( !last ) {
584 while ( !last ) { 584 while ( !last ) {
585 ++count; 585 ++count;
586 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 586 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
587 if ( recursOn( incidenceStart.date() ) ) { 587 if ( recursOn( incidenceStart.date() ) ) {
588 last = true; // exit while llop 588 last = true; // exit while llop
589 } else { 589 } else {
590 if ( last ) { // no alarm on last recurrence 590 if ( last ) { // no alarm on last recurrence
591 return QDateTime (); 591 return QDateTime ();
592 } 592 }
593 int year = incidenceStart.date().year(); 593 int year = incidenceStart.date().year();
594 // workaround for bug in recurrence 594 // workaround for bug in recurrence
595 if ( count == 100 || year < 1980 || year > 5000 ) { 595 if ( count == 100 || year < 1000 || year > 5000 ) {
596 return QDateTime (); 596 return QDateTime ();
597 } 597 }
598 incidenceStart = incidenceStart.addSecs( 1 ); 598 incidenceStart = incidenceStart.addSecs( 1 );
599 } 599 }
600 } 600 }
601 } else { 601 } else {
602 return QDateTime (); 602 return QDateTime ();
603 } 603 }
604 } else { 604 } else {
605 if ( hasStartDate () ) { 605 if ( hasStartDate () ) {
606 incidenceStart = dtStart(); 606 incidenceStart = dtStart();
607 } 607 }
608 if ( type() =="Todo" ) { 608 if ( type() =="Todo" ) {
609 if ( ((Todo*)this)->hasDueDate() ) 609 if ( ((Todo*)this)->hasDueDate() )
610 incidenceStart = ((Todo*)this)->dtDue(); 610 incidenceStart = ((Todo*)this)->dtDue();
611
612 } 611 }
613 } 612 }
614 if ( incidenceStart > dt ) 613 if ( incidenceStart > dt )
615 *ok = true; 614 *ok = true;
616 return incidenceStart; 615 return incidenceStart;
617} 616}