summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Unidiff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 45e3128..2a57724 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -161,81 +161,91 @@ bool CalendarLocal::mergeCalendar( Calendar* remote )
161 } 161 }
162 return true; 162 return true;
163} 163}
164 164
165 165
166bool CalendarLocal::addCalendarFile( QString name, int id ) 166bool CalendarLocal::addCalendarFile( QString name, int id )
167{ 167{
168 CalendarLocal calendar( timeZoneId() ); 168 CalendarLocal calendar( timeZoneId() );
169 calendar.setDefaultCalendar( id ); 169 calendar.setDefaultCalendar( id );
170 if ( calendar.load( name ) ) { 170 if ( calendar.load( name ) ) {
171 addCalendar( &calendar ); 171 addCalendar( &calendar );
172 return true; 172 return true;
173 } 173 }
174 return false; 174 return false;
175} 175}
176void CalendarLocal::setSyncEventsEnabled() 176void CalendarLocal::setSyncEventsEnabled()
177{ 177{
178 Event * ev; 178 Event * ev;
179 ev = mEventList.first(); 179 ev = mEventList.first();
180 while ( ev ) { 180 while ( ev ) {
181 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 181 if ( ev->uid().left(15) == QString("last-syncEvent-") )
182 ev->setCalEnabled( true ); 182 ev->setCalEnabled( true );
183 ev = mEventList.next(); 183 ev = mEventList.next();
184 } 184 }
185} 185}
186void CalendarLocal::setSyncEventsReadOnly() 186void CalendarLocal::setSyncEventsReadOnly()
187{ 187{
188 Event * ev; 188 Event * ev;
189 ev = mEventList.first(); 189 ev = mEventList.first();
190 while ( ev ) { 190 while ( ev ) {
191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) { 191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
192 ev->setReadOnly( true ); 192 ev->setReadOnly( true );
193 ev->setCalID( 1 );
194 } 193 }
195 ev = mEventList.next(); 194 ev = mEventList.next();
196 } 195 }
197} 196}
197
198void CalendarLocal::addCalendar( Calendar* cal ) 198void CalendarLocal::addCalendar( Calendar* cal )
199{ 199{
200 cal->setDontDeleteIncidencesOnClose(); 200 cal->setDontDeleteIncidencesOnClose();
201 setSyncEventsEnabled();
201 { 202 {
202 QPtrList<Event> EventList = cal->rawEvents(); 203 QPtrList<Event> EventList = cal->rawEvents();
204 QPtrList<Event> el;
203 Event * ev = EventList.first(); 205 Event * ev = EventList.first();
204 while ( ev ) { 206 while ( ev ) {
207 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
208 Event * se = event( ev->uid() );
209 if ( se )
210 el.append( se );
211 }
205 ev->unRegisterObserver( cal ); 212 ev->unRegisterObserver( cal );
206 ev->registerObserver( this ); 213 ev->registerObserver( this );
207 mEventList.append( ev ); 214 mEventList.append( ev );
208 ev = EventList.next(); 215 ev = EventList.next();
209 } 216 }
217 for ( ev = el.first(); ev; ev = el.next() ) {
218 deleteIncidence ( ev );
219 }
210 } 220 }
211 { 221 {
212 222
213 QPtrList<Todo> TodoList = cal->rawTodos(); 223 QPtrList<Todo> TodoList = cal->rawTodos();
214 Todo * ev = TodoList.first(); 224 Todo * ev = TodoList.first();
215 while ( ev ) { 225 while ( ev ) {
216 QString rel = ev->relatedToUid(); 226 QString rel = ev->relatedToUid();
217 if ( !rel.isEmpty() ){ 227 if ( !rel.isEmpty() ){
218 ev->setRelatedTo ( 0 ); 228 ev->setRelatedTo ( 0 );
219 ev->setRelatedToUid( rel ); 229 ev->setRelatedToUid( rel );
220 } 230 }
221 ev = TodoList.next(); 231 ev = TodoList.next();
222 } 232 }
223 //TodoList = cal->rawTodos(); 233 //TodoList = cal->rawTodos();
224 ev = TodoList.first(); 234 ev = TodoList.first();
225 while ( ev ) { 235 while ( ev ) {
226 ev->unRegisterObserver( cal ); 236 ev->unRegisterObserver( cal );
227 ev->registerObserver( this ); 237 ev->registerObserver( this );
228 mTodoList.append( ev ); 238 mTodoList.append( ev );
229 setupRelations( ev ); 239 setupRelations( ev );
230 ev = TodoList.next(); 240 ev = TodoList.next();
231 } 241 }
232 } 242 }
233 { 243 {
234 QPtrList<Journal> JournalList = cal->journals(); 244 QPtrList<Journal> JournalList = cal->journals();
235 Journal * ev = JournalList.first(); 245 Journal * ev = JournalList.first();
236 while ( ev ) { 246 while ( ev ) {
237 ev->unRegisterObserver( cal ); 247 ev->unRegisterObserver( cal );
238 ev->registerObserver( this ); 248 ev->registerObserver( this );
239 mJournalList.append( ev ); 249 mJournalList.append( ev );
240 ev = JournalList.next(); 250 ev = JournalList.next();
241 } 251 }
@@ -974,64 +984,77 @@ void CalendarLocal::setCalendarRemove( int id )
974 QPtrList<Event> EventList = mEventList; 984 QPtrList<Event> EventList = mEventList;
975 Event * ev = EventList.first(); 985 Event * ev = EventList.first();
976 while ( ev ) { 986 while ( ev ) {
977 if ( ev->calID() == id ) 987 if ( ev->calID() == id )
978 deleteEvent( ev ); 988 deleteEvent( ev );
979 ev = EventList.next(); 989 ev = EventList.next();
980 } 990 }
981 } 991 }
982 { 992 {
983 993
984 QPtrList<Todo> TodoList = mTodoList; 994 QPtrList<Todo> TodoList = mTodoList;
985 Todo * ev = TodoList.first(); 995 Todo * ev = TodoList.first();
986 while ( ev ) { 996 while ( ev ) {
987 if ( ev->calID() == id ) 997 if ( ev->calID() == id )
988 deleteTodo( ev ); 998 deleteTodo( ev );
989 ev = TodoList.next(); 999 ev = TodoList.next();
990 } 1000 }
991 } 1001 }
992 { 1002 {
993 QPtrList<Journal> JournalList = mJournalList; 1003 QPtrList<Journal> JournalList = mJournalList;
994 Journal * ev = JournalList.first(); 1004 Journal * ev = JournalList.first();
995 while ( ev ) { 1005 while ( ev ) {
996 if ( ev->calID() == id ) 1006 if ( ev->calID() == id )
997 deleteJournal( ev ); 1007 deleteJournal( ev );
998 ev = JournalList.next(); 1008 ev = JournalList.next();
999 } 1009 }
1000 } 1010 }
1001 1011
1002 clearUndo(0); 1012 clearUndo(0);
1003 1013
1004} 1014}
1005 1015
1016void CalendarLocal::setAllCalendarEnabled( bool enable )
1017{
1018 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1019 it->setCalEnabled( enable );
1020
1021 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
1022 it->setCalEnabled( enable );
1023
1024 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
1025 it->setCalEnabled( enable );
1026
1027
1028}
1006void CalendarLocal::setCalendarEnabled( int id, bool enable ) 1029void CalendarLocal::setCalendarEnabled( int id, bool enable )
1007{ 1030{
1008 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1031 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1009 if ( it->calID() == id ) it->setCalEnabled( enable ); 1032 if ( it->calID() == id ) it->setCalEnabled( enable );
1010 1033
1011 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 1034 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
1012 if ( it->calID() == id ) it->setCalEnabled( enable ); 1035 if ( it->calID() == id ) it->setCalEnabled( enable );
1013 1036
1014 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 1037 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
1015 if ( it->calID() == id ) it->setCalEnabled( enable ); 1038 if ( it->calID() == id ) it->setCalEnabled( enable );
1016 1039
1017} 1040}
1018 1041
1019void CalendarLocal::setReadOnly( int id, bool enable ) 1042void CalendarLocal::setReadOnly( int id, bool enable )
1020{ 1043{
1021 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1044 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1022 if ( it->calID() == id ) it->setReadOnly( enable ); 1045 if ( it->calID() == id ) it->setReadOnly( enable );
1023 1046
1024 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 1047 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
1025 if ( it->calID() == id ) it->setReadOnly( enable ); 1048 if ( it->calID() == id ) it->setReadOnly( enable );
1026 1049
1027 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 1050 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
1028 if ( it->calID() == id ) it->setReadOnly( enable ); 1051 if ( it->calID() == id ) it->setReadOnly( enable );
1029 1052
1030} 1053}
1031 1054
1032void CalendarLocal::setAlarmEnabled( int id, bool enable ) 1055void CalendarLocal::setAlarmEnabled( int id, bool enable )
1033{ 1056{
1034 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1057 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1035 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 1058 if ( it->calID() == id ) it->setAlarmEnabled( enable );
1036 1059
1037 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 1060 for ( Event *it = mEventList.first(); it; it = mEventList.next() )