summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
authorzautrix <zautrix>2005-06-14 08:23:19 (UTC)
committer zautrix <zautrix>2005-06-14 08:23:19 (UTC)
commit1dccb9dd9ea32989ecec33c72a3ebd873dce048e (patch) (unidiff)
tree6b7dd7e4696c91a3afaba89225dd4f31f376a30b /libkcal/calendarlocal.cpp
parentb3743f5abe0a95c9ffeadf6701c9943f604febd6 (diff)
downloadkdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.zip
kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.gz
kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.bz2
faster filter
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp55
1 files changed, 37 insertions, 18 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 749d9f6..336c3e8 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -36,502 +36,514 @@
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
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 if ( mDeleteIncidencesOnClose ) 68 if ( mDeleteIncidencesOnClose )
69 close(); 69 close();
70} 70}
71bool CalendarLocal::addCalendarFile( QString name, int id ) 71bool CalendarLocal::addCalendarFile( QString name, int id )
72{ 72{
73 CalendarLocal calendar( timeZoneId() ); 73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id ); 74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) { 75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar ); 76 addCalendar( &calendar );
77 return true; 77 return true;
78 } 78 }
79 return false; 79 return false;
80} 80}
81void CalendarLocal::addCalendar( Calendar* cal ) 81void CalendarLocal::addCalendar( Calendar* cal )
82{ 82{
83 cal->setDontDeleteIncidencesOnClose(); 83 cal->setDontDeleteIncidencesOnClose();
84 { 84 {
85 QPtrList<Event> EventList = cal->rawEvents(); 85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first(); 86 Event * ev = EventList.first();
87 while ( ev ) { 87 while ( ev ) {
88 ev->unRegisterObserver( cal ); 88 ev->unRegisterObserver( cal );
89 ev->registerObserver( this ); 89 ev->registerObserver( this );
90 mEventList.append( ev ); 90 mEventList.append( ev );
91 ev = EventList.next(); 91 ev = EventList.next();
92 } 92 }
93 } 93 }
94 { 94 {
95 95
96 QPtrList<Todo> TodoList = cal->rawTodos(); 96 QPtrList<Todo> TodoList = cal->rawTodos();
97 Todo * ev = TodoList.first(); 97 Todo * ev = TodoList.first();
98 while ( ev ) { 98 while ( ev ) {
99 QString rel = ev->relatedToUid(); 99 QString rel = ev->relatedToUid();
100 if ( !rel.isEmpty() ){ 100 if ( !rel.isEmpty() ){
101 ev->setRelatedTo ( 0 ); 101 ev->setRelatedTo ( 0 );
102 ev->setRelatedToUid( rel ); 102 ev->setRelatedToUid( rel );
103 } 103 }
104 ev = TodoList.next(); 104 ev = TodoList.next();
105 } 105 }
106 //TodoList = cal->rawTodos(); 106 //TodoList = cal->rawTodos();
107 ev = TodoList.first(); 107 ev = TodoList.first();
108 while ( ev ) { 108 while ( ev ) {
109 ev->unRegisterObserver( cal ); 109 ev->unRegisterObserver( cal );
110 ev->registerObserver( this ); 110 ev->registerObserver( this );
111 mTodoList.append( ev ); 111 mTodoList.append( ev );
112 setupRelations( ev ); 112 setupRelations( ev );
113 ev = TodoList.next(); 113 ev = TodoList.next();
114 } 114 }
115 } 115 }
116 { 116 {
117 QPtrList<Journal> JournalList = cal->journals(); 117 QPtrList<Journal> JournalList = cal->journals();
118 Journal * ev = JournalList.first(); 118 Journal * ev = JournalList.first();
119 while ( ev ) { 119 while ( ev ) {
120 ev->unRegisterObserver( cal ); 120 ev->unRegisterObserver( cal );
121 ev->registerObserver( this ); 121 ev->registerObserver( this );
122 mJournalList.append( ev ); 122 mJournalList.append( ev );
123 ev = JournalList.next(); 123 ev = JournalList.next();
124 } 124 }
125 } 125 }
126 setModified( true ); 126 setModified( true );
127} 127}
128bool CalendarLocal::load( const QString &fileName ) 128bool CalendarLocal::load( const QString &fileName )
129{ 129{
130 FileStorage storage( this, fileName ); 130 FileStorage storage( this, fileName );
131 return storage.load(); 131 return storage.load();
132} 132}
133 133
134bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 134bool CalendarLocal::save( const QString &fileName, CalFormat *format )
135{ 135{
136 FileStorage storage( this, fileName, format ); 136 FileStorage storage( this, fileName, format );
137 return storage.save(); 137 return storage.save();
138} 138}
139 139
140void CalendarLocal::close() 140void CalendarLocal::close()
141{ 141{
142 142
143 Todo * i; 143 Todo * i;
144 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 144 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
145 145
146 mEventList.setAutoDelete( true ); 146 mEventList.setAutoDelete( true );
147 mTodoList.setAutoDelete( true ); 147 mTodoList.setAutoDelete( true );
148 mJournalList.setAutoDelete( false ); 148 mJournalList.setAutoDelete( false );
149 149
150 mEventList.clear(); 150 mEventList.clear();
151 mTodoList.clear(); 151 mTodoList.clear();
152 mJournalList.clear(); 152 mJournalList.clear();
153 153
154 mEventList.setAutoDelete( false ); 154 mEventList.setAutoDelete( false );
155 mTodoList.setAutoDelete( false ); 155 mTodoList.setAutoDelete( false );
156 mJournalList.setAutoDelete( false ); 156 mJournalList.setAutoDelete( false );
157 157
158 setModified( false ); 158 setModified( false );
159} 159}
160 160
161bool CalendarLocal::addAnniversaryNoDup( Event *event ) 161bool CalendarLocal::addAnniversaryNoDup( Event *event )
162{ 162{
163 QString cat; 163 QString cat;
164 bool isBirthday = true; 164 bool isBirthday = true;
165 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 165 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
166 isBirthday = false; 166 isBirthday = false;
167 cat = i18n( "Anniversary" ); 167 cat = i18n( "Anniversary" );
168 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 168 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
169 isBirthday = true; 169 isBirthday = true;
170 cat = i18n( "Birthday" ); 170 cat = i18n( "Birthday" );
171 } else { 171 } else {
172 qDebug("addAnniversaryNoDup called without fitting category! "); 172 qDebug("addAnniversaryNoDup called without fitting category! ");
173 return false; 173 return false;
174 } 174 }
175 Event * eve; 175 Event * eve;
176 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 176 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
177 if ( !(eve->categories().contains( cat ) )) 177 if ( !(eve->categories().contains( cat ) ))
178 continue; 178 continue;
179 // now we have an event with fitting category 179 // now we have an event with fitting category
180 if ( eve->dtStart().date() != event->dtStart().date() ) 180 if ( eve->dtStart().date() != event->dtStart().date() )
181 continue; 181 continue;
182 // now we have an event with fitting category+date 182 // now we have an event with fitting category+date
183 if ( eve->summary() != event->summary() ) 183 if ( eve->summary() != event->summary() )
184 continue; 184 continue;
185 // now we have an event with fitting category+date+summary 185 // now we have an event with fitting category+date+summary
186 return false; 186 return false;
187 } 187 }
188 return addEvent( event ); 188 return addEvent( event );
189 189
190} 190}
191bool CalendarLocal::addEventNoDup( Event *event ) 191bool CalendarLocal::addEventNoDup( Event *event )
192{ 192{
193 Event * eve; 193 Event * eve;
194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
195 if ( *eve == *event ) { 195 if ( *eve == *event ) {
196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
197 return false; 197 return false;
198 } 198 }
199 } 199 }
200 return addEvent( event ); 200 return addEvent( event );
201} 201}
202 202
203bool CalendarLocal::addEvent( Event *event ) 203bool CalendarLocal::addEvent( Event *event )
204{ 204{
205 insertEvent( event ); 205 insertEvent( event );
206 206
207 event->registerObserver( this ); 207 event->registerObserver( this );
208 208
209 setModified( true ); 209 setModified( true );
210 event->setCalID( mDefaultCalendar ); 210 event->setCalID( mDefaultCalendar );
211 event->setCalEnabled( true ); 211 event->setCalEnabled( true );
212 212
213 return true; 213 return true;
214} 214}
215 215
216void CalendarLocal::deleteEvent( Event *event ) 216void CalendarLocal::deleteEvent( Event *event )
217{ 217{
218 if ( mUndoIncidence ) delete mUndoIncidence; 218 if ( mUndoIncidence ) delete mUndoIncidence;
219 mUndoIncidence = event->clone(); 219 mUndoIncidence = event->clone();
220 if ( mEventList.removeRef( event ) ) { 220 if ( mEventList.removeRef( event ) ) {
221 setModified( true ); 221 setModified( true );
222 } 222 }
223} 223}
224 224
225 225
226Event *CalendarLocal::event( const QString &uid ) 226Event *CalendarLocal::event( const QString &uid )
227{ 227{
228 228 Event *event;
229 Event *event; 229 Event *retVal = 0;
230 230 for ( event = mEventList.first(); event; event = mEventList.next() ) {
231 for ( event = mEventList.first(); event; event = mEventList.next() ) { 231 if ( event->calEnabled() && event->uid() == uid ) {
232 if ( event->uid() == uid && event->calEnabled() ) { 232 if ( retVal ) {
233 return event; 233 if ( retVal->calID() > event->calID() ) {
234 retVal = event;
235 }
236 } else {
237 retVal = event;
238 }
239 }
234 } 240 }
235 } 241 return retVal;
236
237 return 0;
238} 242}
239bool CalendarLocal::addTodoNoDup( Todo *todo ) 243bool CalendarLocal::addTodoNoDup( Todo *todo )
240{ 244{
241 Todo * eve; 245 Todo * eve;
242 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 246 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
243 if ( *eve == *todo ) { 247 if ( *eve == *todo ) {
244 //qDebug("duplicate todo found! not inserted! "); 248 //qDebug("duplicate todo found! not inserted! ");
245 return false; 249 return false;
246 } 250 }
247 } 251 }
248 return addTodo( todo ); 252 return addTodo( todo );
249} 253}
250bool CalendarLocal::addTodo( Todo *todo ) 254bool CalendarLocal::addTodo( Todo *todo )
251{ 255{
252 mTodoList.append( todo ); 256 mTodoList.append( todo );
253 257
254 todo->registerObserver( this ); 258 todo->registerObserver( this );
255 259
256 // Set up subtask relations 260 // Set up subtask relations
257 setupRelations( todo ); 261 setupRelations( todo );
258 262
259 setModified( true ); 263 setModified( true );
260 todo->setCalID( mDefaultCalendar ); 264 todo->setCalID( mDefaultCalendar );
261 todo->setCalEnabled( true ); 265 todo->setCalEnabled( true );
262 return true; 266 return true;
263} 267}
264 268
265void CalendarLocal::deleteTodo( Todo *todo ) 269void CalendarLocal::deleteTodo( Todo *todo )
266{ 270{
267 // Handle orphaned children 271 // Handle orphaned children
268 if ( mUndoIncidence ) delete mUndoIncidence; 272 if ( mUndoIncidence ) delete mUndoIncidence;
269 removeRelations( todo ); 273 removeRelations( todo );
270 mUndoIncidence = todo->clone(); 274 mUndoIncidence = todo->clone();
271 275
272 if ( mTodoList.removeRef( todo ) ) { 276 if ( mTodoList.removeRef( todo ) ) {
273 setModified( true ); 277 setModified( true );
274 } 278 }
275} 279}
276 280
277QPtrList<Todo> CalendarLocal::rawTodos() 281QPtrList<Todo> CalendarLocal::rawTodos()
278{ 282{
279 QPtrList<Todo> el; 283 QPtrList<Todo> el;
280 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 284 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
281 if ( it->calEnabled() ) el.append( it ); 285 if ( it->calEnabled() ) el.append( it );
282 return el; 286 return el;
283} 287}
284Todo *CalendarLocal::todo( QString syncProf, QString id ) 288Todo *CalendarLocal::todo( QString syncProf, QString id )
285{ 289{
286 Todo *todo; 290 Todo *todo;
287 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 291 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
288 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 292 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
289 } 293 }
290 294
291 return 0; 295 return 0;
292} 296}
293void CalendarLocal::removeSyncInfo( QString syncProfile) 297void CalendarLocal::removeSyncInfo( QString syncProfile)
294{ 298{
295 QPtrList<Incidence> all = rawIncidences() ; 299 QPtrList<Incidence> all = rawIncidences() ;
296 Incidence *inc; 300 Incidence *inc;
297 for ( inc = all.first(); inc; inc = all.next() ) { 301 for ( inc = all.first(); inc; inc = all.next() ) {
298 inc->removeID( syncProfile ); 302 inc->removeID( syncProfile );
299 } 303 }
300 if ( syncProfile.isEmpty() ) { 304 if ( syncProfile.isEmpty() ) {
301 QPtrList<Event> el; 305 QPtrList<Event> el;
302 Event *todo; 306 Event *todo;
303 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 307 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
304 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 308 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
305 el.append( todo ); 309 el.append( todo );
306 } 310 }
307 for ( todo = el.first(); todo; todo = el.next() ) { 311 for ( todo = el.first(); todo; todo = el.next() ) {
308 deleteIncidence ( todo ); 312 deleteIncidence ( todo );
309 } 313 }
310 } else { 314 } else {
311 Event *lse = event( "last-syncEvent-"+ syncProfile); 315 Event *lse = event( "last-syncEvent-"+ syncProfile);
312 if ( lse ) 316 if ( lse )
313 deleteIncidence ( lse ); 317 deleteIncidence ( lse );
314 } 318 }
315} 319}
316QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 320QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
317{ 321{
318 QPtrList<Event> el; 322 QPtrList<Event> el;
319 Event *todo; 323 Event *todo;
320 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 324 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
321 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 325 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
322 if ( todo->summary().left(3) == "E: " ) 326 if ( todo->summary().left(3) == "E: " )
323 el.append( todo ); 327 el.append( todo );
324 } 328 }
325 329
326 return el; 330 return el;
327 331
328} 332}
329Event *CalendarLocal::event( QString syncProf, QString id ) 333Event *CalendarLocal::event( QString syncProf, QString id )
330{ 334{
331 Event *todo; 335 Event *todo;
332 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 336 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
333 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 337 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
334 } 338 }
335 339
336 return 0; 340 return 0;
337} 341}
338Todo *CalendarLocal::todo( const QString &uid ) 342Todo *CalendarLocal::todo( const QString &uid )
339{ 343{
340 Todo *todo; 344 Todo *todo;;
345 Todo *retVal = 0;
341 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 346 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
342 if ( todo->calEnabled() && todo->uid() == uid ) return todo; 347 if ( todo->calEnabled() && todo->uid() == uid ) {
348 if ( retVal ) {
349 if ( retVal->calID() > todo->calID() ) {
350 retVal = todo;
351 }
352 } else {
353 retVal = todo;
354 }
355 }
343 } 356 }
344 357 return retVal;
345 return 0;
346} 358}
347QString CalendarLocal::nextSummary() const 359QString CalendarLocal::nextSummary() const
348{ 360{
349 return mNextSummary; 361 return mNextSummary;
350} 362}
351QDateTime CalendarLocal::nextAlarmEventDateTime() const 363QDateTime CalendarLocal::nextAlarmEventDateTime() const
352{ 364{
353 return mNextAlarmEventDateTime; 365 return mNextAlarmEventDateTime;
354} 366}
355void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 367void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
356{ 368{
357 //mNextAlarmIncidence 369 //mNextAlarmIncidence
358 //mNextAlarmDateTime 370 //mNextAlarmDateTime
359 //return mNextSummary; 371 //return mNextSummary;
360 //return mNextAlarmEventDateTime; 372 //return mNextAlarmEventDateTime;
361 bool newNextAlarm = false; 373 bool newNextAlarm = false;
362 bool computeNextAlarm = false; 374 bool computeNextAlarm = false;
363 bool ok; 375 bool ok;
364 int offset; 376 int offset;
365 QDateTime nextA; 377 QDateTime nextA;
366 // QString nextSum; 378 // QString nextSum;
367 //QDateTime nextEvent; 379 //QDateTime nextEvent;
368 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 380 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
369 computeNextAlarm = true; 381 computeNextAlarm = true;
370 } else { 382 } else {
371 if ( ! deleted ) { 383 if ( ! deleted ) {
372 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 384 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
373 if ( ok ) { 385 if ( ok ) {
374 if ( nextA < mNextAlarmDateTime ) { 386 if ( nextA < mNextAlarmDateTime ) {
375 deRegisterAlarm(); 387 deRegisterAlarm();
376 mNextAlarmDateTime = nextA; 388 mNextAlarmDateTime = nextA;
377 mNextSummary = incidence->summary(); 389 mNextSummary = incidence->summary();
378 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 390 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
379 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 391 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
380 newNextAlarm = true; 392 newNextAlarm = true;
381 mNextAlarmIncidence = incidence; 393 mNextAlarmIncidence = incidence;
382 } else { 394 } else {
383 if ( incidence == mNextAlarmIncidence ) { 395 if ( incidence == mNextAlarmIncidence ) {
384 computeNextAlarm = true; 396 computeNextAlarm = true;
385 } 397 }
386 } 398 }
387 } else { 399 } else {
388 if ( mNextAlarmIncidence == incidence ) { 400 if ( mNextAlarmIncidence == incidence ) {
389 computeNextAlarm = true; 401 computeNextAlarm = true;
390 } 402 }
391 } 403 }
392 } else { // deleted 404 } else { // deleted
393 if ( incidence == mNextAlarmIncidence ) { 405 if ( incidence == mNextAlarmIncidence ) {
394 computeNextAlarm = true; 406 computeNextAlarm = true;
395 } 407 }
396 } 408 }
397 } 409 }
398 if ( computeNextAlarm ) { 410 if ( computeNextAlarm ) {
399 deRegisterAlarm(); 411 deRegisterAlarm();
400 nextA = nextAlarm( 1000 ); 412 nextA = nextAlarm( 1000 );
401 if (! mNextAlarmIncidence ) { 413 if (! mNextAlarmIncidence ) {
402 return; 414 return;
403 } 415 }
404 newNextAlarm = true; 416 newNextAlarm = true;
405 } 417 }
406 if ( newNextAlarm ) 418 if ( newNextAlarm )
407 registerAlarm(); 419 registerAlarm();
408} 420}
409QString CalendarLocal:: getAlarmNotification() 421QString CalendarLocal:: getAlarmNotification()
410{ 422{
411 QString ret; 423 QString ret;
412 // this should not happen 424 // this should not happen
413 if (! mNextAlarmIncidence ) 425 if (! mNextAlarmIncidence )
414 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 426 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
415 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 427 Alarm* alarm = mNextAlarmIncidence->alarms().first();
416 if ( alarm->type() == Alarm::Procedure ) { 428 if ( alarm->type() == Alarm::Procedure ) {
417 ret = "proc_alarm" + alarm->programFile()+"+++"; 429 ret = "proc_alarm" + alarm->programFile()+"+++";
418 } else { 430 } else {
419 ret = "audio_alarm" +alarm->audioFile() +"+++"; 431 ret = "audio_alarm" +alarm->audioFile() +"+++";
420 } 432 }
421 ret += "cal_alarm"+ mNextSummary.left( 25 ); 433 ret += "cal_alarm"+ mNextSummary.left( 25 );
422 if ( mNextSummary.length() > 25 ) 434 if ( mNextSummary.length() > 25 )
423 ret += "\n" + mNextSummary.mid(25, 25 ); 435 ret += "\n" + mNextSummary.mid(25, 25 );
424 ret+= "\n"+mNextAlarmEventDateTimeString; 436 ret+= "\n"+mNextAlarmEventDateTimeString;
425 return ret; 437 return ret;
426} 438}
427void CalendarLocal::registerAlarm() 439void CalendarLocal::registerAlarm()
428{ 440{
429 mLastAlarmNotificationString = getAlarmNotification(); 441 mLastAlarmNotificationString = getAlarmNotification();
430 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 442 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
431 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 443 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
432// #ifndef DESKTOP_VERSION 444// #ifndef DESKTOP_VERSION
433// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 445// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
434// #endif 446// #endif
435} 447}
436void CalendarLocal::deRegisterAlarm() 448void CalendarLocal::deRegisterAlarm()
437{ 449{
438 if ( mLastAlarmNotificationString.isNull() ) 450 if ( mLastAlarmNotificationString.isNull() )
439 return; 451 return;
440 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 452 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
441 453
442 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 454 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
443 mNextAlarmEventDateTime = QDateTime(); 455 mNextAlarmEventDateTime = QDateTime();
444// #ifndef DESKTOP_VERSION 456// #ifndef DESKTOP_VERSION
445// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 457// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
446// #endif 458// #endif
447} 459}
448 460
449QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 461QPtrList<Todo> CalendarLocal::todos( const QDate &date )
450{ 462{
451 QPtrList<Todo> todos; 463 QPtrList<Todo> todos;
452 464
453 Todo *todo; 465 Todo *todo;
454 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 466 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
455 if ( !todo->calEnabled() ) continue; 467 if ( !todo->calEnabled() ) continue;
456 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 468 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
457 todos.append( todo ); 469 todos.append( todo );
458 } 470 }
459 } 471 }
460 472
461 filter()->apply( &todos ); 473 filter()->apply( &todos );
462 return todos; 474 return todos;
463} 475}
464void CalendarLocal::reInitAlarmSettings() 476void CalendarLocal::reInitAlarmSettings()
465{ 477{
466 if ( !mNextAlarmIncidence ) { 478 if ( !mNextAlarmIncidence ) {
467 nextAlarm( 1000 ); 479 nextAlarm( 1000 );
468 } 480 }
469 deRegisterAlarm(); 481 deRegisterAlarm();
470 mNextAlarmIncidence = 0; 482 mNextAlarmIncidence = 0;
471 checkAlarmForIncidence( 0, false ); 483 checkAlarmForIncidence( 0, false );
472 484
473} 485}
474 486
475 487
476 488
477QDateTime CalendarLocal::nextAlarm( int daysTo ) 489QDateTime CalendarLocal::nextAlarm( int daysTo )
478{ 490{
479 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); 491 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo );
480 QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); 492 QDateTime start = QDateTime::currentDateTime().addSecs( 30 );
481 QDateTime next; 493 QDateTime next;
482 Event *e; 494 Event *e;
483 bool ok; 495 bool ok;
484 bool found = false; 496 bool found = false;
485 int offset; 497 int offset;
486 mNextAlarmIncidence = 0; 498 mNextAlarmIncidence = 0;
487 for( e = mEventList.first(); e; e = mEventList.next() ) { 499 for( e = mEventList.first(); e; e = mEventList.next() ) {
488 if ( !e->calEnabled() ) continue; 500 if ( !e->calEnabled() ) continue;
489 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 501 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
490 if ( ok ) { 502 if ( ok ) {
491 if ( next < nextA ) { 503 if ( next < nextA ) {
492 nextA = next; 504 nextA = next;
493 found = true; 505 found = true;
494 mNextSummary = e->summary(); 506 mNextSummary = e->summary();
495 mNextAlarmEventDateTime = next.addSecs(offset ) ; 507 mNextAlarmEventDateTime = next.addSecs(offset ) ;
496 mNextAlarmIncidence = (Incidence *) e; 508 mNextAlarmIncidence = (Incidence *) e;
497 } 509 }
498 } 510 }
499 } 511 }
500 Todo *t; 512 Todo *t;
501 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 513 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
502 if ( !t->calEnabled() ) continue; 514 if ( !t->calEnabled() ) continue;
503 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 515 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
504 if ( ok ) { 516 if ( ok ) {
505 if ( next < nextA ) { 517 if ( next < nextA ) {
506 nextA = next; 518 nextA = next;
507 found = true; 519 found = true;
508 mNextSummary = t->summary(); 520 mNextSummary = t->summary();
509 mNextAlarmEventDateTime = next.addSecs(offset ); 521 mNextAlarmEventDateTime = next.addSecs(offset );
510 mNextAlarmIncidence = (Incidence *) t; 522 mNextAlarmIncidence = (Incidence *) t;
511 } 523 }
512 } 524 }
513 } 525 }
514 if ( mNextAlarmIncidence ) { 526 if ( mNextAlarmIncidence ) {
515 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 527 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
516 mNextAlarmDateTime = nextA; 528 mNextAlarmDateTime = nextA;
517 } 529 }
518 return nextA; 530 return nextA;
519} 531}
520Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) 532Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
521{ 533{
522 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); 534 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
523} 535}
524 536
525Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 537Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
526{ 538{
527 539
528 Alarm::List alarms; 540 Alarm::List alarms;
529 541
530 Event *e; 542 Event *e;
531 543
532 for( e = mEventList.first(); e; e = mEventList.next() ) { 544 for( e = mEventList.first(); e; e = mEventList.next() ) {
533 if ( !e->calEnabled() ) continue; 545 if ( !e->calEnabled() ) continue;
534 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); 546 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
535 else appendAlarms( alarms, e, from, to ); 547 else appendAlarms( alarms, e, from, to );
536 } 548 }
537 549
@@ -597,294 +609,301 @@ void CalendarLocal::update( IncidenceBase *incidence )
597 // need to verify with ical documentation. 609 // need to verify with ical documentation.
598 610
599 setModified( true ); 611 setModified( true );
600} 612}
601 613
602void CalendarLocal::insertEvent( Event *event ) 614void CalendarLocal::insertEvent( Event *event )
603{ 615{
604 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 616 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
605} 617}
606 618
607 619
608QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 620QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
609{ 621{
610 QPtrList<Event> eventList; 622 QPtrList<Event> eventList;
611 623
612 Event *event; 624 Event *event;
613 for( event = mEventList.first(); event; event = mEventList.next() ) { 625 for( event = mEventList.first(); event; event = mEventList.next() ) {
614 if ( !event->calEnabled() ) continue; 626 if ( !event->calEnabled() ) continue;
615 if ( event->doesRecur() ) { 627 if ( event->doesRecur() ) {
616 if ( event->isMultiDay() ) { 628 if ( event->isMultiDay() ) {
617 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 629 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
618 int i; 630 int i;
619 for ( i = 0; i <= extraDays; i++ ) { 631 for ( i = 0; i <= extraDays; i++ ) {
620 if ( event->recursOn( qd.addDays( -i ) ) ) { 632 if ( event->recursOn( qd.addDays( -i ) ) ) {
621 eventList.append( event ); 633 eventList.append( event );
622 break; 634 break;
623 } 635 }
624 } 636 }
625 } else { 637 } else {
626 if ( event->recursOn( qd ) ) 638 if ( event->recursOn( qd ) )
627 eventList.append( event ); 639 eventList.append( event );
628 } 640 }
629 } else { 641 } else {
630 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 642 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
631 eventList.append( event ); 643 eventList.append( event );
632 } 644 }
633 } 645 }
634 } 646 }
635 647
636 if ( !sorted ) { 648 if ( !sorted ) {
637 return eventList; 649 return eventList;
638 } 650 }
639 651
640 // kdDebug(5800) << "Sorting events for date\n" << endl; 652 // kdDebug(5800) << "Sorting events for date\n" << endl;
641 // now, we have to sort it based on dtStart.time() 653 // now, we have to sort it based on dtStart.time()
642 QPtrList<Event> eventListSorted; 654 QPtrList<Event> eventListSorted;
643 Event *sortEvent; 655 Event *sortEvent;
644 for ( event = eventList.first(); event; event = eventList.next() ) { 656 for ( event = eventList.first(); event; event = eventList.next() ) {
645 sortEvent = eventListSorted.first(); 657 sortEvent = eventListSorted.first();
646 int i = 0; 658 int i = 0;
647 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 659 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
648 { 660 {
649 i++; 661 i++;
650 sortEvent = eventListSorted.next(); 662 sortEvent = eventListSorted.next();
651 } 663 }
652 eventListSorted.insert( i, event ); 664 eventListSorted.insert( i, event );
653 } 665 }
654 return eventListSorted; 666 return eventListSorted;
655} 667}
656 668
657 669
658QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 670QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
659 bool inclusive ) 671 bool inclusive )
660{ 672{
661 Event *event = 0; 673 Event *event = 0;
662 674
663 QPtrList<Event> eventList; 675 QPtrList<Event> eventList;
664 676
665 // Get non-recurring events 677 // Get non-recurring events
666 for( event = mEventList.first(); event; event = mEventList.next() ) { 678 for( event = mEventList.first(); event; event = mEventList.next() ) {
667 if ( !event->calEnabled() ) continue; 679 if ( !event->calEnabled() ) continue;
668 if ( event->doesRecur() ) { 680 if ( event->doesRecur() ) {
669 QDate rStart = event->dtStart().date(); 681 QDate rStart = event->dtStart().date();
670 bool found = false; 682 bool found = false;
671 if ( inclusive ) { 683 if ( inclusive ) {
672 if ( rStart >= start && rStart <= end ) { 684 if ( rStart >= start && rStart <= end ) {
673 // Start date of event is in range. Now check for end date. 685 // Start date of event is in range. Now check for end date.
674 // if duration is negative, event recurs forever, so do not include it. 686 // if duration is negative, event recurs forever, so do not include it.
675 if ( event->recurrence()->duration() == 0 ) { // End date set 687 if ( event->recurrence()->duration() == 0 ) { // End date set
676 QDate rEnd = event->recurrence()->endDate(); 688 QDate rEnd = event->recurrence()->endDate();
677 if ( rEnd >= start && rEnd <= end ) { // End date within range 689 if ( rEnd >= start && rEnd <= end ) { // End date within range
678 found = true; 690 found = true;
679 } 691 }
680 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 692 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
681 // TODO: Calculate end date from duration. Should be done in Event 693 // TODO: Calculate end date from duration. Should be done in Event
682 // For now exclude all events with a duration. 694 // For now exclude all events with a duration.
683 } 695 }
684 } 696 }
685 } else { 697 } else {
686 bool founOne; 698 bool founOne;
687 QDate next = event->getNextOccurence( start, &founOne ).date(); 699 QDate next = event->getNextOccurence( start, &founOne ).date();
688 if ( founOne ) { 700 if ( founOne ) {
689 if ( next <= end ) { 701 if ( next <= end ) {
690 found = true; 702 found = true;
691 } 703 }
692 } 704 }
693 705
694 /* 706 /*
695 // crap !!! 707 // crap !!!
696 if ( rStart <= end ) { // Start date not after range 708 if ( rStart <= end ) { // Start date not after range
697 if ( rStart >= start ) { // Start date within range 709 if ( rStart >= start ) { // Start date within range
698 found = true; 710 found = true;
699 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 711 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
700 found = true; 712 found = true;
701 } else if ( event->recurrence()->duration() == 0 ) { // End date set 713 } else if ( event->recurrence()->duration() == 0 ) { // End date set
702 QDate rEnd = event->recurrence()->endDate(); 714 QDate rEnd = event->recurrence()->endDate();
703 if ( rEnd >= start && rEnd <= end ) { // End date within range 715 if ( rEnd >= start && rEnd <= end ) { // End date within range
704 found = true; 716 found = true;
705 } 717 }
706 } else { // Duration set 718 } else { // Duration set
707 // TODO: Calculate end date from duration. Should be done in Event 719 // TODO: Calculate end date from duration. Should be done in Event
708 // For now include all events with a duration. 720 // For now include all events with a duration.
709 found = true; 721 found = true;
710 } 722 }
711 } 723 }
712 */ 724 */
713 725
714 } 726 }
715 727
716 if ( found ) eventList.append( event ); 728 if ( found ) eventList.append( event );
717 } else { 729 } else {
718 QDate s = event->dtStart().date(); 730 QDate s = event->dtStart().date();
719 QDate e = event->dtEnd().date(); 731 QDate e = event->dtEnd().date();
720 732
721 if ( inclusive ) { 733 if ( inclusive ) {
722 if ( s >= start && e <= end ) { 734 if ( s >= start && e <= end ) {
723 eventList.append( event ); 735 eventList.append( event );
724 } 736 }
725 } else { 737 } else {
726 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { 738 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) {
727 eventList.append( event ); 739 eventList.append( event );
728 } 740 }
729 } 741 }
730 } 742 }
731 } 743 }
732 744
733 return eventList; 745 return eventList;
734} 746}
735 747
736QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 748QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
737{ 749{
738 return rawEventsForDate( qdt.date() ); 750 return rawEventsForDate( qdt.date() );
739} 751}
740 752
741QPtrList<Event> CalendarLocal::rawEvents() 753QPtrList<Event> CalendarLocal::rawEvents()
742{ 754{
743 QPtrList<Event> el; 755 QPtrList<Event> el;
744 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 756 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
745 if ( it->calEnabled() ) el.append( it ); 757 if ( it->calEnabled() ) el.append( it );
746 return el; 758 return el;
747} 759}
748 760
749bool CalendarLocal::addJournal(Journal *journal) 761bool CalendarLocal::addJournal(Journal *journal)
750{ 762{
751 if ( journal->dtStart().isValid()) 763 if ( journal->dtStart().isValid())
752 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; 764 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
753 else 765 else
754 kdDebug(5800) << "Adding Journal without a DTSTART" << endl; 766 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
755 767
756 mJournalList.append(journal); 768 mJournalList.append(journal);
757 769
758 journal->registerObserver( this ); 770 journal->registerObserver( this );
759 771
760 setModified( true ); 772 setModified( true );
761 journal->setCalID( mDefaultCalendar ); 773 journal->setCalID( mDefaultCalendar );
762 journal->setCalEnabled( true ); 774 journal->setCalEnabled( true );
763 return true; 775 return true;
764} 776}
765 777
766void CalendarLocal::deleteJournal( Journal *journal ) 778void CalendarLocal::deleteJournal( Journal *journal )
767{ 779{
768 if ( mUndoIncidence ) delete mUndoIncidence; 780 if ( mUndoIncidence ) delete mUndoIncidence;
769 mUndoIncidence = journal->clone(); 781 mUndoIncidence = journal->clone();
770 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 782 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
771 if ( mJournalList.removeRef(journal) ) { 783 if ( mJournalList.removeRef(journal) ) {
772 setModified( true ); 784 setModified( true );
773 } 785 }
774} 786}
775 787
776Journal *CalendarLocal::journal( const QDate &date ) 788Journal *CalendarLocal::journal( const QDate &date )
777{ 789{
778// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 790// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
779 791
780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 792 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
781 if ( it->calEnabled() && it->dtStart().date() == date ) 793 if ( it->calEnabled() && it->dtStart().date() == date )
782 return it; 794 return it;
783 795
784 return 0; 796 return 0;
785} 797}
786 798
787Journal *CalendarLocal::journal( const QString &uid ) 799Journal *CalendarLocal::journal( const QString &uid )
788{ 800{
789 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 801 Journal * retVal = 0;
790 if ( it->calEnabled() && it->uid() == uid ) 802 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
791 return it; 803 if ( it->calEnabled() && it->uid() == uid ) {
792 804 if ( retVal ) {
793 return 0; 805 if ( retVal->calID() > it->calID() ) {
806 retVal = it;
807 }
808 } else {
809 retVal = it;
810 }
811 }
812 return retVal;
794} 813}
795 814
796QPtrList<Journal> CalendarLocal::journals() 815QPtrList<Journal> CalendarLocal::journals()
797{ 816{
798 QPtrList<Journal> el; 817 QPtrList<Journal> el;
799 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 818 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
800 if ( it->calEnabled() ) el.append( it ); 819 if ( it->calEnabled() ) el.append( it );
801 return el; 820 return el;
802} 821}
803void CalendarLocal::setCalendarRemove( int id ) 822void CalendarLocal::setCalendarRemove( int id )
804{ 823{
805 824
806 { 825 {
807 QPtrList<Event> EventList = mEventList; 826 QPtrList<Event> EventList = mEventList;
808 Event * ev = EventList.first(); 827 Event * ev = EventList.first();
809 while ( ev ) { 828 while ( ev ) {
810 if ( ev->calID() == id ) 829 if ( ev->calID() == id )
811 deleteEvent( ev ); 830 deleteEvent( ev );
812 ev = EventList.next(); 831 ev = EventList.next();
813 } 832 }
814 } 833 }
815 { 834 {
816 835
817 QPtrList<Todo> TodoList = mTodoList; 836 QPtrList<Todo> TodoList = mTodoList;
818 Todo * ev = TodoList.first(); 837 Todo * ev = TodoList.first();
819 while ( ev ) { 838 while ( ev ) {
820 if ( ev->calID() == id ) 839 if ( ev->calID() == id )
821 deleteTodo( ev ); 840 deleteTodo( ev );
822 ev = TodoList.next(); 841 ev = TodoList.next();
823 } 842 }
824 } 843 }
825 { 844 {
826 QPtrList<Journal> JournalList = mJournalList; 845 QPtrList<Journal> JournalList = mJournalList;
827 Journal * ev = JournalList.first(); 846 Journal * ev = JournalList.first();
828 while ( ev ) { 847 while ( ev ) {
829 if ( ev->calID() == id ) 848 if ( ev->calID() == id )
830 deleteJournal( ev ); 849 deleteJournal( ev );
831 ev = JournalList.next(); 850 ev = JournalList.next();
832 } 851 }
833 } 852 }
834 853
835 if ( mUndoIncidence ) delete mUndoIncidence; 854 if ( mUndoIncidence ) delete mUndoIncidence;
836 mUndoIncidence = 0; 855 mUndoIncidence = 0;
837 856
838} 857}
839 858
840void CalendarLocal::setCalendarEnabled( int id, bool enable ) 859void CalendarLocal::setCalendarEnabled( int id, bool enable )
841{ 860{
842 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 861 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
843 if ( it->calID() == id ) it->setCalEnabled( enable ); 862 if ( it->calID() == id ) it->setCalEnabled( enable );
844 863
845 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 864 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
846 if ( it->calID() == id ) it->setCalEnabled( enable ); 865 if ( it->calID() == id ) it->setCalEnabled( enable );
847 866
848 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 867 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
849 if ( it->calID() == id ) it->setCalEnabled( enable ); 868 if ( it->calID() == id ) it->setCalEnabled( enable );
850 869
851} 870}
852 871
853void CalendarLocal::setReadOnly( int id, bool enable ) 872void CalendarLocal::setReadOnly( int id, bool enable )
854{ 873{
855 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 874 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
856 if ( it->calID() == id ) it->setReadOnly( enable ); 875 if ( it->calID() == id ) it->setReadOnly( enable );
857 876
858 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 877 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
859 if ( it->calID() == id ) it->setReadOnly( enable ); 878 if ( it->calID() == id ) it->setReadOnly( enable );
860 879
861 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 880 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
862 if ( it->calID() == id ) it->setReadOnly( enable ); 881 if ( it->calID() == id ) it->setReadOnly( enable );
863 882
864} 883}
865 884
866void CalendarLocal::setAlarmEnabled( int id, bool enable ) 885void CalendarLocal::setAlarmEnabled( int id, bool enable )
867{ 886{
868 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 887 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
869 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 888 if ( it->calID() == id ) it->setAlarmEnabled( enable );
870 889
871 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 890 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
872 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 891 if ( it->calID() == id ) it->setAlarmEnabled( enable );
873 892
874 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 893 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
875 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 894 if ( it->calID() == id ) it->setAlarmEnabled( enable );
876 reInitAlarmSettings(); 895 reInitAlarmSettings();
877 896
878} 897}
879void CalendarLocal::setDefaultCalendarEnabledOnly() 898void CalendarLocal::setDefaultCalendarEnabledOnly()
880{ 899{
881 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 900 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
882 it->setCalEnabled( it->calID() == mDefaultCalendar ); 901 it->setCalEnabled( it->calID() == mDefaultCalendar );
883 902
884 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 903 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
885 it->setCalEnabled( it->calID() == mDefaultCalendar); 904 it->setCalEnabled( it->calID() == mDefaultCalendar);
886 905
887 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 906 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
888 it->setCalEnabled( it->calID() == mDefaultCalendar); 907 it->setCalEnabled( it->calID() == mDefaultCalendar);
889 908
890} 909}