author | zautrix <zautrix> | 2005-01-31 17:16:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 17:16:55 (UTC) |
commit | 8e627854bec00289be27915b81458cf22bbb000f (patch) (unidiff) | |
tree | 18db63d50f031122b5069927c2491ac8cf5c6295 /libkcal/calendarlocal.cpp | |
parent | ec037c4616342c1b3976c55db98b775f48e0d455 (diff) | |
download | kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.zip kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.tar.gz kdepimpi-8e627854bec00289be27915b81458cf22bbb000f.tar.bz2 |
sss
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e75154b..0eba6a9 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -542,97 +542,96 @@ 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 | ||
587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
588 | bool inclusive ) | 588 | bool inclusive ) |
589 | { | 589 | { |
590 | qDebug("CalendarLocal::rawEvents called "); | ||
591 | Event *event = 0; | 590 | Event *event = 0; |
592 | 591 | ||
593 | QPtrList<Event> eventList; | 592 | QPtrList<Event> eventList; |
594 | 593 | ||
595 | // Get non-recurring events | 594 | // Get non-recurring events |
596 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 595 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
597 | if ( event->doesRecur() ) { | 596 | if ( event->doesRecur() ) { |
598 | QDate rStart = event->dtStart().date(); | 597 | QDate rStart = event->dtStart().date(); |
599 | bool found = false; | 598 | bool found = false; |
600 | if ( inclusive ) { | 599 | if ( inclusive ) { |
601 | if ( rStart >= start && rStart <= end ) { | 600 | if ( rStart >= start && rStart <= end ) { |
602 | // Start date of event is in range. Now check for end date. | 601 | // Start date of event is in range. Now check for end date. |
603 | // if duration is negative, event recurs forever, so do not include it. | 602 | // if duration is negative, event recurs forever, so do not include it. |
604 | if ( event->recurrence()->duration() == 0 ) { // End date set | 603 | if ( event->recurrence()->duration() == 0 ) { // End date set |
605 | QDate rEnd = event->recurrence()->endDate(); | 604 | QDate rEnd = event->recurrence()->endDate(); |
606 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 605 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
607 | found = true; | 606 | found = true; |
608 | } | 607 | } |
609 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 608 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
610 | // TODO: Calculate end date from duration. Should be done in Event | 609 | // TODO: Calculate end date from duration. Should be done in Event |
611 | // For now exclude all events with a duration. | 610 | // For now exclude all events with a duration. |
612 | } | 611 | } |
613 | } | 612 | } |
614 | } else { | 613 | } else { |
615 | bool founOne; | 614 | bool founOne; |
616 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 615 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
617 | if ( founOne ) { | 616 | if ( founOne ) { |
618 | if ( next <= end ) { | 617 | if ( next <= end ) { |
619 | found = true; | 618 | found = true; |
620 | } | 619 | } |
621 | } | 620 | } |
622 | 621 | ||
623 | /* | 622 | /* |
624 | // crap !!! | 623 | // crap !!! |
625 | if ( rStart <= end ) { // Start date not after range | 624 | if ( rStart <= end ) { // Start date not after range |
626 | if ( rStart >= start ) { // Start date within range | 625 | if ( rStart >= start ) { // Start date within range |
627 | found = true; | 626 | found = true; |
628 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 627 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
629 | found = true; | 628 | found = true; |
630 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 629 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
631 | QDate rEnd = event->recurrence()->endDate(); | 630 | QDate rEnd = event->recurrence()->endDate(); |
632 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 631 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
633 | found = true; | 632 | found = true; |
634 | } | 633 | } |
635 | } else { // Duration set | 634 | } else { // Duration set |
636 | // TODO: Calculate end date from duration. Should be done in Event | 635 | // TODO: Calculate end date from duration. Should be done in Event |
637 | // For now include all events with a duration. | 636 | // For now include all events with a duration. |
638 | found = true; | 637 | found = true; |