summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 418bfca..ca64e66 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -715,153 +715,155 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
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 ( ( e >= start && s <= 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
764QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 764QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
765{ 765{
766 return rawEventsForDate( qdt.date() ); 766 return rawEventsForDate( qdt.date() );
767} 767}
768 768
769QPtrList<Event> CalendarLocal::rawEvents() 769QPtrList<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
777bool CalendarLocal::addJournal(Journal *journal) 777bool CalendarLocal::addJournal(Journal *journal)
778{ 778{
779 if ( journal->dtStart().isValid()) 779 mJournalList.append(journal);
780 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
781 else
782 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
783
784 mJournalList.append(journal);
785 780
786 journal->registerObserver( this ); 781 journal->registerObserver( this );
787 782
788 setModified( true ); 783 setModified( true );
789 journal->setCalID( mDefaultCalendar ); 784 journal->setCalID( mDefaultCalendar );
790 journal->setCalEnabled( true ); 785 journal->setCalEnabled( true );
791 return true; 786 return true;
792} 787}
793 788
794void CalendarLocal::deleteJournal( Journal *journal ) 789void CalendarLocal::deleteJournal( Journal *journal )
795{ 790{
796 if ( mUndoIncidence ) delete mUndoIncidence; 791 if ( mUndoIncidence ) delete mUndoIncidence;
797 mUndoIncidence = journal->clone(); 792 mUndoIncidence = journal->clone();
798 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 793 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
799 if ( mJournalList.removeRef(journal) ) { 794 if ( mJournalList.removeRef(journal) ) {
800 setModified( true ); 795 setModified( true );
801 } 796 }
802} 797}
803 798
799QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
800{
801 QPtrList<Journal> el;
802 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
803 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
804 return el;
805}
804Journal *CalendarLocal::journal( const QDate &date ) 806Journal *CalendarLocal::journal( const QDate &date )
805{ 807{
806// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 808// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
807 809
808 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 810 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
809 if ( it->calEnabled() && it->dtStart().date() == date ) 811 if ( it->calEnabled() && it->dtStart().date() == date )
810 return it; 812 return it;
811 813
812 return 0; 814 return 0;
813} 815}
814 816
815Journal *CalendarLocal::journal( const QString &uid ) 817Journal *CalendarLocal::journal( const QString &uid )
816{ 818{
817 Journal * retVal = 0; 819 Journal * retVal = 0;
818 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 820 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
819 if ( it->calEnabled() && it->uid() == uid ) { 821 if ( it->calEnabled() && it->uid() == uid ) {
820 if ( retVal ) { 822 if ( retVal ) {
821 if ( retVal->calID() > it->calID() ) { 823 if ( retVal->calID() > it->calID() ) {
822 retVal = it; 824 retVal = it;
823 } 825 }
824 } else { 826 } else {
825 retVal = it; 827 retVal = it;
826 } 828 }
827 } 829 }
828 return retVal; 830 return retVal;
829} 831}
830 832
831QPtrList<Journal> CalendarLocal::journals() 833QPtrList<Journal> CalendarLocal::journals()
832{ 834{
833 QPtrList<Journal> el; 835 QPtrList<Journal> el;
834 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 836 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
835 if ( it->calEnabled() ) el.append( it ); 837 if ( it->calEnabled() ) el.append( it );
836 return el; 838 return el;
837} 839}
838void CalendarLocal::setCalendarRemove( int id ) 840void CalendarLocal::setCalendarRemove( int id )
839{ 841{
840 842
841 { 843 {
842 QPtrList<Event> EventList = mEventList; 844 QPtrList<Event> EventList = mEventList;
843 Event * ev = EventList.first(); 845 Event * ev = EventList.first();
844 while ( ev ) { 846 while ( ev ) {
845 if ( ev->calID() == id ) 847 if ( ev->calID() == id )
846 deleteEvent( ev ); 848 deleteEvent( ev );
847 ev = EventList.next(); 849 ev = EventList.next();
848 } 850 }
849 } 851 }
850 { 852 {
851 853
852 QPtrList<Todo> TodoList = mTodoList; 854 QPtrList<Todo> TodoList = mTodoList;
853 Todo * ev = TodoList.first(); 855 Todo * ev = TodoList.first();
854 while ( ev ) { 856 while ( ev ) {
855 if ( ev->calID() == id ) 857 if ( ev->calID() == id )
856 deleteTodo( ev ); 858 deleteTodo( ev );
857 ev = TodoList.next(); 859 ev = TodoList.next();
858 } 860 }
859 } 861 }
860 { 862 {
861 QPtrList<Journal> JournalList = mJournalList; 863 QPtrList<Journal> JournalList = mJournalList;
862 Journal * ev = JournalList.first(); 864 Journal * ev = JournalList.first();
863 while ( ev ) { 865 while ( ev ) {
864 if ( ev->calID() == id ) 866 if ( ev->calID() == id )
865 deleteJournal( ev ); 867 deleteJournal( ev );
866 ev = JournalList.next(); 868 ev = JournalList.next();
867 } 869 }