-rw-r--r-- | libkcal/calendarlocal.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 18f1af8..418bfca 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -658,193 +658,193 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | |||
658 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 658 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
659 | eventList.append( event ); | 659 | eventList.append( event ); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | if ( !sorted ) { | 664 | if ( !sorted ) { |
665 | return eventList; | 665 | return eventList; |
666 | } | 666 | } |
667 | 667 | ||
668 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 668 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
669 | // now, we have to sort it based on dtStart.time() | 669 | // now, we have to sort it based on dtStart.time() |
670 | QPtrList<Event> eventListSorted; | 670 | QPtrList<Event> eventListSorted; |
671 | Event *sortEvent; | 671 | Event *sortEvent; |
672 | for ( event = eventList.first(); event; event = eventList.next() ) { | 672 | for ( event = eventList.first(); event; event = eventList.next() ) { |
673 | sortEvent = eventListSorted.first(); | 673 | sortEvent = eventListSorted.first(); |
674 | int i = 0; | 674 | int i = 0; |
675 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 675 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
676 | { | 676 | { |
677 | i++; | 677 | i++; |
678 | sortEvent = eventListSorted.next(); | 678 | sortEvent = eventListSorted.next(); |
679 | } | 679 | } |
680 | eventListSorted.insert( i, event ); | 680 | eventListSorted.insert( i, event ); |
681 | } | 681 | } |
682 | return eventListSorted; | 682 | return eventListSorted; |
683 | } | 683 | } |
684 | 684 | ||
685 | 685 | ||
686 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 686 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
687 | bool inclusive ) | 687 | bool inclusive ) |
688 | { | 688 | { |
689 | Event *event = 0; | 689 | Event *event = 0; |
690 | 690 | ||
691 | QPtrList<Event> eventList; | 691 | QPtrList<Event> eventList; |
692 | 692 | ||
693 | // Get non-recurring events | 693 | // Get non-recurring events |
694 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 694 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
695 | if ( !event->calEnabled() ) continue; | 695 | if ( !event->calEnabled() ) continue; |
696 | if ( event->doesRecur() ) { | 696 | if ( event->doesRecur() ) { |
697 | QDate rStart = event->dtStart().date(); | 697 | QDate rStart = event->dtStart().date(); |
698 | bool found = false; | 698 | bool found = false; |
699 | if ( inclusive ) { | 699 | if ( inclusive ) { |
700 | if ( rStart >= start && rStart <= end ) { | 700 | if ( rStart >= start && rStart <= end ) { |
701 | // Start date of event is in range. Now check for end date. | 701 | // Start date of event is in range. Now check for end date. |
702 | // if duration is negative, event recurs forever, so do not include it. | 702 | // if duration is negative, event recurs forever, so do not include it. |
703 | if ( event->recurrence()->duration() == 0 ) { // End date set | 703 | if ( event->recurrence()->duration() == 0 ) { // End date set |
704 | QDate rEnd = event->recurrence()->endDate(); | 704 | QDate rEnd = event->recurrence()->endDate(); |
705 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 705 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
706 | found = true; | 706 | found = true; |
707 | } | 707 | } |
708 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 708 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
709 | // TODO: Calculate end date from duration. Should be done in Event | 709 | // TODO: Calculate end date from duration. Should be done in Event |
710 | // For now exclude all events with a duration. | 710 | // For now exclude all events with a duration. |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } else { | 713 | } else { |
714 | bool founOne; | 714 | bool founOne; |
715 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 715 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
716 | if ( founOne ) { | 716 | if ( founOne ) { |
717 | if ( next <= end ) { | 717 | if ( next <= end ) { |
718 | found = true; | 718 | found = true; |
719 | } | 719 | } |
720 | } | 720 | } |
721 | 721 | ||
722 | /* | 722 | /* |
723 | // crap !!! | 723 | // crap !!! |
724 | if ( rStart <= end ) { // Start date not after range | 724 | if ( rStart <= end ) { // Start date not after range |
725 | if ( rStart >= start ) { // Start date within range | 725 | if ( rStart >= start ) { // Start date within range |
726 | found = true; | 726 | found = true; |
727 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 727 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
728 | found = true; | 728 | found = true; |
729 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 729 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
730 | QDate rEnd = event->recurrence()->endDate(); | 730 | QDate rEnd = event->recurrence()->endDate(); |
731 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 731 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
732 | found = true; | 732 | found = true; |
733 | } | 733 | } |
734 | } else { // Duration set | 734 | } else { // Duration set |
735 | // TODO: Calculate end date from duration. Should be done in Event | 735 | // TODO: Calculate end date from duration. Should be done in Event |
736 | // For now include all events with a duration. | 736 | // For now include all events with a duration. |
737 | found = true; | 737 | found = true; |
738 | } | 738 | } |
739 | } | 739 | } |
740 | */ | 740 | */ |
741 | 741 | ||
742 | } | 742 | } |
743 | 743 | ||
744 | if ( found ) eventList.append( event ); | 744 | if ( found ) eventList.append( event ); |
745 | } else { | 745 | } else { |
746 | QDate s = event->dtStart().date(); | 746 | QDate s = event->dtStart().date(); |
747 | QDate e = event->dtEnd().date(); | 747 | QDate e = event->dtEnd().date(); |
748 | 748 | ||
749 | if ( inclusive ) { | 749 | if ( inclusive ) { |
750 | if ( s >= start && e <= end ) { | 750 | if ( s >= start && e <= end ) { |
751 | eventList.append( event ); | 751 | eventList.append( event ); |
752 | } | 752 | } |
753 | } else { | 753 | } else { |
754 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 754 | if ( ( e >= start && s <= end ) ) { |
755 | eventList.append( event ); | 755 | eventList.append( event ); |
756 | } | 756 | } |
757 | } | 757 | } |
758 | } | 758 | } |
759 | } | 759 | } |
760 | 760 | ||
761 | return eventList; | 761 | return eventList; |
762 | } | 762 | } |
763 | 763 | ||
764 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 764 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
765 | { | 765 | { |
766 | return rawEventsForDate( qdt.date() ); | 766 | return rawEventsForDate( qdt.date() ); |
767 | } | 767 | } |
768 | 768 | ||
769 | QPtrList<Event> CalendarLocal::rawEvents() | 769 | QPtrList<Event> CalendarLocal::rawEvents() |
770 | { | 770 | { |
771 | QPtrList<Event> el; | 771 | QPtrList<Event> el; |
772 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 772 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
773 | if ( it->calEnabled() ) el.append( it ); | 773 | if ( it->calEnabled() ) el.append( it ); |
774 | return el; | 774 | return el; |
775 | } | 775 | } |
776 | 776 | ||
777 | bool CalendarLocal::addJournal(Journal *journal) | 777 | bool CalendarLocal::addJournal(Journal *journal) |
778 | { | 778 | { |
779 | if ( journal->dtStart().isValid()) | 779 | if ( journal->dtStart().isValid()) |
780 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 780 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
781 | else | 781 | else |
782 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 782 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
783 | 783 | ||
784 | mJournalList.append(journal); | 784 | mJournalList.append(journal); |
785 | 785 | ||
786 | journal->registerObserver( this ); | 786 | journal->registerObserver( this ); |
787 | 787 | ||
788 | setModified( true ); | 788 | setModified( true ); |
789 | journal->setCalID( mDefaultCalendar ); | 789 | journal->setCalID( mDefaultCalendar ); |
790 | journal->setCalEnabled( true ); | 790 | journal->setCalEnabled( true ); |
791 | return true; | 791 | return true; |
792 | } | 792 | } |
793 | 793 | ||
794 | void CalendarLocal::deleteJournal( Journal *journal ) | 794 | void CalendarLocal::deleteJournal( Journal *journal ) |
795 | { | 795 | { |
796 | if ( mUndoIncidence ) delete mUndoIncidence; | 796 | if ( mUndoIncidence ) delete mUndoIncidence; |
797 | mUndoIncidence = journal->clone(); | 797 | mUndoIncidence = journal->clone(); |
798 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 798 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
799 | if ( mJournalList.removeRef(journal) ) { | 799 | if ( mJournalList.removeRef(journal) ) { |
800 | setModified( true ); | 800 | setModified( true ); |
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | Journal *CalendarLocal::journal( const QDate &date ) | 804 | Journal *CalendarLocal::journal( const QDate &date ) |
805 | { | 805 | { |
806 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 806 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
807 | 807 | ||
808 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 808 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
809 | if ( it->calEnabled() && it->dtStart().date() == date ) | 809 | if ( it->calEnabled() && it->dtStart().date() == date ) |
810 | return it; | 810 | return it; |
811 | 811 | ||
812 | return 0; | 812 | return 0; |
813 | } | 813 | } |
814 | 814 | ||
815 | Journal *CalendarLocal::journal( const QString &uid ) | 815 | Journal *CalendarLocal::journal( const QString &uid ) |
816 | { | 816 | { |
817 | Journal * retVal = 0; | 817 | Journal * retVal = 0; |
818 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 818 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
819 | if ( it->calEnabled() && it->uid() == uid ) { | 819 | if ( it->calEnabled() && it->uid() == uid ) { |
820 | if ( retVal ) { | 820 | if ( retVal ) { |
821 | if ( retVal->calID() > it->calID() ) { | 821 | if ( retVal->calID() > it->calID() ) { |
822 | retVal = it; | 822 | retVal = it; |
823 | } | 823 | } |
824 | } else { | 824 | } else { |
825 | retVal = it; | 825 | retVal = it; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | return retVal; | 828 | return retVal; |
829 | } | 829 | } |
830 | 830 | ||
831 | QPtrList<Journal> CalendarLocal::journals() | 831 | QPtrList<Journal> CalendarLocal::journals() |
832 | { | 832 | { |
833 | QPtrList<Journal> el; | 833 | QPtrList<Journal> el; |
834 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 834 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
835 | if ( it->calEnabled() ) el.append( it ); | 835 | if ( it->calEnabled() ) el.append( it ); |
836 | return el; | 836 | return el; |
837 | } | 837 | } |
838 | void CalendarLocal::setCalendarRemove( int id ) | 838 | void CalendarLocal::setCalendarRemove( int id ) |
839 | { | 839 | { |
840 | 840 | ||
841 | { | 841 | { |
842 | QPtrList<Event> EventList = mEventList; | 842 | QPtrList<Event> EventList = mEventList; |
843 | Event * ev = EventList.first(); | 843 | Event * ev = EventList.first(); |
844 | while ( ev ) { | 844 | while ( ev ) { |
845 | if ( ev->calID() == id ) | 845 | if ( ev->calID() == id ) |
846 | deleteEvent( ev ); | 846 | deleteEvent( ev ); |
847 | ev = EventList.next(); | 847 | ev = EventList.next(); |
848 | } | 848 | } |
849 | } | 849 | } |
850 | { | 850 | { |