summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -52,35 +52,73 @@ CalendarLocal::CalendarLocal()
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 close(); 68 if ( mDeleteIncidencesOnClose )
69 close();
70}
71bool CalendarLocal::addCalendarFile( QString name, int id )
72{
73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar );
77 return true;
78 }
79 return false;
80}
81void CalendarLocal::addCalendar( Calendar* cal )
82{
83 cal->setDontDeleteIncidencesOnClose();
84 {
85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first();
87 while ( ev ) {
88 mEventList.append( ev );
89 ev = EventList.next();
90 }
91 }
92 {
93 QPtrList<Todo> TodoList = cal->rawTodos();
94 Todo * ev = TodoList.first();
95 while ( ev ) {
96 mTodoList.append( ev );
97 ev = TodoList.next();
98 }
99 }
100 {
101 QPtrList<Journal> JournalList = cal->journals();
102 Journal * ev = JournalList.first();
103 while ( ev ) {
104 mJournalList.append( ev );
105 ev = JournalList.next();
106 }
107 }
69} 108}
70
71bool CalendarLocal::load( const QString &fileName ) 109bool CalendarLocal::load( const QString &fileName )
72{ 110{
73 FileStorage storage( this, fileName ); 111 FileStorage storage( this, fileName );
74 return storage.load(); 112 return storage.load();
75} 113}
76 114
77bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 115bool CalendarLocal::save( const QString &fileName, CalFormat *format )
78{ 116{
79 FileStorage storage( this, fileName, format ); 117 FileStorage storage( this, fileName, format );
80 return storage.save(); 118 return storage.save();
81} 119}
82 120
83void CalendarLocal::close() 121void CalendarLocal::close()
84{ 122{
85 123
86 Todo * i; 124 Todo * i;
@@ -743,32 +781,46 @@ QPtrList<Journal> CalendarLocal::journals()
743 if ( it->calEnabled() ) el.append( it ); 781 if ( it->calEnabled() ) el.append( it );
744 return el; 782 return el;
745} 783}
746 784
747void CalendarLocal::setCalendarEnabled( int id, bool enable ) 785void CalendarLocal::setCalendarEnabled( int id, bool enable )
748{ 786{
749 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 787 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
750 if ( it->calID() == id ) it->setCalEnabled( enable ); 788 if ( it->calID() == id ) it->setCalEnabled( enable );
751 789
752 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 790 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
753 if ( it->calID() == id ) it->setCalEnabled( enable ); 791 if ( it->calID() == id ) it->setCalEnabled( enable );
754 792
755 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 793 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
756 if ( it->calID() == id ) it->setCalEnabled( enable ); 794 if ( it->calID() == id ) it->setCalEnabled( enable );
757 795
758} 796}
797
798void CalendarLocal::setReadOnly( int id, bool enable )
799{
800 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
801 if ( it->calID() == id ) it->setReadOnly( enable );
802
803 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
804 if ( it->calID() == id ) it->setReadOnly( enable );
805
806 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
807 if ( it->calID() == id ) it->setReadOnly( enable );
808
809}
810
759void CalendarLocal::setAlarmEnabled( int id, bool enable ) 811void CalendarLocal::setAlarmEnabled( int id, bool enable )
760{ 812{
761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
762 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 814 if ( it->calID() == id ) it->setAlarmEnabled( enable );
763 815
764 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 816 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
765 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 817 if ( it->calID() == id ) it->setAlarmEnabled( enable );
766 818
767 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 819 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
768 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 820 if ( it->calID() == id ) it->setAlarmEnabled( enable );
769 821
770} 822}
771void CalendarLocal::setDefaultCalendarEnabledOnly() 823void CalendarLocal::setDefaultCalendarEnabledOnly()
772{ 824{
773 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 825 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
774 it->setCalEnabled( it->calID() == mDefaultCalendar ); 826 it->setCalEnabled( it->calID() == mDefaultCalendar );