author | zautrix <zautrix> | 2005-07-30 08:08:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-30 08:08:47 (UTC) |
commit | 055928e26613f4ab249bd82be86890ed278372f6 (patch) (unidiff) | |
tree | 0dfc4cba815a2ba0b30c71fbd74b340e2bcc8572 | |
parent | 9cbd19485635dc0edacd14403e4c63d6d469bfce (diff) | |
download | kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.zip kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.gz kdepimpi-055928e26613f4ab249bd82be86890ed278372f6.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/calendarlocal.cpp | 31 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/journal.cpp | 4 |
3 files changed, 24 insertions, 12 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 5baa7dc..e8c969f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -175,309 +175,322 @@ bool CalendarLocal::addCalendarFile( QString name, int id ) | |||
175 | } | 175 | } |
176 | void CalendarLocal::setSyncEventsReadOnly() | 176 | void CalendarLocal::setSyncEventsReadOnly() |
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->setReadOnly( true ); | 182 | ev->setReadOnly( true ); |
183 | ev = mEventList.next(); | 183 | ev = mEventList.next(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | void CalendarLocal::addCalendar( Calendar* cal ) | 186 | void CalendarLocal::addCalendar( Calendar* cal ) |
187 | { | 187 | { |
188 | cal->setDontDeleteIncidencesOnClose(); | 188 | cal->setDontDeleteIncidencesOnClose(); |
189 | { | 189 | { |
190 | QPtrList<Event> EventList = cal->rawEvents(); | 190 | QPtrList<Event> EventList = cal->rawEvents(); |
191 | Event * ev = EventList.first(); | 191 | Event * ev = EventList.first(); |
192 | while ( ev ) { | 192 | while ( ev ) { |
193 | ev->unRegisterObserver( cal ); | 193 | ev->unRegisterObserver( cal ); |
194 | ev->registerObserver( this ); | 194 | ev->registerObserver( this ); |
195 | mEventList.append( ev ); | 195 | mEventList.append( ev ); |
196 | ev = EventList.next(); | 196 | ev = EventList.next(); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | { | 199 | { |
200 | 200 | ||
201 | QPtrList<Todo> TodoList = cal->rawTodos(); | 201 | QPtrList<Todo> TodoList = cal->rawTodos(); |
202 | Todo * ev = TodoList.first(); | 202 | Todo * ev = TodoList.first(); |
203 | while ( ev ) { | 203 | while ( ev ) { |
204 | QString rel = ev->relatedToUid(); | 204 | QString rel = ev->relatedToUid(); |
205 | if ( !rel.isEmpty() ){ | 205 | if ( !rel.isEmpty() ){ |
206 | ev->setRelatedTo ( 0 ); | 206 | ev->setRelatedTo ( 0 ); |
207 | ev->setRelatedToUid( rel ); | 207 | ev->setRelatedToUid( rel ); |
208 | } | 208 | } |
209 | ev = TodoList.next(); | 209 | ev = TodoList.next(); |
210 | } | 210 | } |
211 | //TodoList = cal->rawTodos(); | 211 | //TodoList = cal->rawTodos(); |
212 | ev = TodoList.first(); | 212 | ev = TodoList.first(); |
213 | while ( ev ) { | 213 | while ( ev ) { |
214 | ev->unRegisterObserver( cal ); | 214 | ev->unRegisterObserver( cal ); |
215 | ev->registerObserver( this ); | 215 | ev->registerObserver( this ); |
216 | mTodoList.append( ev ); | 216 | mTodoList.append( ev ); |
217 | setupRelations( ev ); | 217 | setupRelations( ev ); |
218 | ev = TodoList.next(); | 218 | ev = TodoList.next(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | { | 221 | { |
222 | QPtrList<Journal> JournalList = cal->journals(); | 222 | QPtrList<Journal> JournalList = cal->journals(); |
223 | Journal * ev = JournalList.first(); | 223 | Journal * ev = JournalList.first(); |
224 | while ( ev ) { | 224 | while ( ev ) { |
225 | ev->unRegisterObserver( cal ); | 225 | ev->unRegisterObserver( cal ); |
226 | ev->registerObserver( this ); | 226 | ev->registerObserver( this ); |
227 | mJournalList.append( ev ); | 227 | mJournalList.append( ev ); |
228 | ev = JournalList.next(); | 228 | ev = JournalList.next(); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | setModified( true ); | 231 | setModified( true ); |
232 | } | 232 | } |
233 | bool CalendarLocal::load( const QString &fileName ) | 233 | bool CalendarLocal::load( const QString &fileName ) |
234 | { | 234 | { |
235 | FileStorage storage( this, fileName ); | 235 | FileStorage storage( this, fileName ); |
236 | return storage.load(); | 236 | return storage.load(); |
237 | } | 237 | } |
238 | 238 | ||
239 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 239 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
240 | { | 240 | { |
241 | FileStorage storage( this, fileName, format ); | 241 | FileStorage storage( this, fileName, format ); |
242 | return storage.save(); | 242 | return storage.save(); |
243 | } | 243 | } |
244 | 244 | ||
245 | void CalendarLocal::stopAllTodos() | 245 | void CalendarLocal::stopAllTodos() |
246 | { | 246 | { |
247 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 247 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
248 | it->setRunning( false ); | 248 | it->setRunning( false ); |
249 | 249 | ||
250 | } | 250 | } |
251 | void CalendarLocal::close() | 251 | void CalendarLocal::close() |
252 | { | 252 | { |
253 | 253 | ||
254 | Todo * i; | 254 | Todo * i; |
255 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 255 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
256 | 256 | ||
257 | mEventList.setAutoDelete( true ); | 257 | mEventList.setAutoDelete( true ); |
258 | mTodoList.setAutoDelete( true ); | 258 | mTodoList.setAutoDelete( true ); |
259 | mJournalList.setAutoDelete( true ); | 259 | mJournalList.setAutoDelete( true ); |
260 | 260 | ||
261 | mEventList.clear(); | 261 | mEventList.clear(); |
262 | mTodoList.clear(); | 262 | mTodoList.clear(); |
263 | mJournalList.clear(); | 263 | mJournalList.clear(); |
264 | 264 | ||
265 | mEventList.setAutoDelete( false ); | 265 | mEventList.setAutoDelete( false ); |
266 | mTodoList.setAutoDelete( false ); | 266 | mTodoList.setAutoDelete( false ); |
267 | mJournalList.setAutoDelete( false ); | 267 | mJournalList.setAutoDelete( false ); |
268 | 268 | ||
269 | setModified( false ); | 269 | setModified( false ); |
270 | } | 270 | } |
271 | 271 | void CalendarLocal::clearUndo() | |
272 | { | ||
273 | if ( mUndoIncidence ) { | ||
274 | if ( mUndoIncidence->typeID() == eventID ) | ||
275 | delete ((Event*) mUndoIncidence) ; | ||
276 | else if ( mUndoIncidence->typeID() == todoID ) | ||
277 | delete ( (Todo*) mUndoIncidence ); | ||
278 | else if ( mUndoIncidence->typeID() == journalID ) | ||
279 | delete ( (Journal*) mUndoIncidence ); | ||
280 | else | ||
281 | delete mUndoIncidence; | ||
282 | } | ||
283 | mUndoIncidence = 0; | ||
284 | } | ||
272 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 285 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
273 | { | 286 | { |
274 | QString cat; | 287 | QString cat; |
275 | bool isBirthday = true; | 288 | bool isBirthday = true; |
276 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 289 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
277 | isBirthday = false; | 290 | isBirthday = false; |
278 | cat = i18n( "Anniversary" ); | 291 | cat = i18n( "Anniversary" ); |
279 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 292 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
280 | isBirthday = true; | 293 | isBirthday = true; |
281 | cat = i18n( "Birthday" ); | 294 | cat = i18n( "Birthday" ); |
282 | } else { | 295 | } else { |
283 | qDebug("addAnniversaryNoDup called without fitting category! "); | 296 | qDebug("addAnniversaryNoDup called without fitting category! "); |
284 | return false; | 297 | return false; |
285 | } | 298 | } |
286 | Event * eve; | 299 | Event * eve; |
287 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 300 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
288 | if ( !(eve->categories().contains( cat ) )) | 301 | if ( !(eve->categories().contains( cat ) )) |
289 | continue; | 302 | continue; |
290 | // now we have an event with fitting category | 303 | // now we have an event with fitting category |
291 | if ( eve->dtStart().date() != event->dtStart().date() ) | 304 | if ( eve->dtStart().date() != event->dtStart().date() ) |
292 | continue; | 305 | continue; |
293 | // now we have an event with fitting category+date | 306 | // now we have an event with fitting category+date |
294 | if ( eve->summary() != event->summary() ) | 307 | if ( eve->summary() != event->summary() ) |
295 | continue; | 308 | continue; |
296 | // now we have an event with fitting category+date+summary | 309 | // now we have an event with fitting category+date+summary |
297 | return false; | 310 | return false; |
298 | } | 311 | } |
299 | return addEvent( event ); | 312 | return addEvent( event ); |
300 | 313 | ||
301 | } | 314 | } |
302 | bool CalendarLocal::addEventNoDup( Event *event ) | 315 | bool CalendarLocal::addEventNoDup( Event *event ) |
303 | { | 316 | { |
304 | Event * eve; | 317 | Event * eve; |
305 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 318 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
306 | if ( *eve == *event ) { | 319 | if ( *eve == *event ) { |
307 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 320 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
308 | return false; | 321 | return false; |
309 | } | 322 | } |
310 | } | 323 | } |
311 | return addEvent( event ); | 324 | return addEvent( event ); |
312 | } | 325 | } |
313 | 326 | ||
314 | bool CalendarLocal::addEvent( Event *event ) | 327 | bool CalendarLocal::addEvent( Event *event ) |
315 | { | 328 | { |
316 | insertEvent( event ); | 329 | insertEvent( event ); |
317 | 330 | ||
318 | event->registerObserver( this ); | 331 | event->registerObserver( this ); |
319 | 332 | ||
320 | setModified( true ); | 333 | setModified( true ); |
321 | if ( event->calID() == 0 ) | 334 | if ( event->calID() == 0 ) |
322 | event->setCalID( mDefaultCalendar ); | 335 | event->setCalID( mDefaultCalendar ); |
323 | event->setCalEnabled( true ); | 336 | event->setCalEnabled( true ); |
324 | 337 | ||
325 | return true; | 338 | return true; |
326 | } | 339 | } |
327 | 340 | ||
328 | void CalendarLocal::deleteEvent( Event *event ) | 341 | void CalendarLocal::deleteEvent( Event *event ) |
329 | { | 342 | { |
330 | if ( mUndoIncidence ) delete mUndoIncidence; | 343 | clearUndo(); |
331 | mUndoIncidence = event->clone(); | 344 | mUndoIncidence = event; |
332 | if ( mEventList.removeRef( event ) ) { | 345 | if ( mEventList.removeRef( event ) ) { |
333 | setModified( true ); | 346 | setModified( true ); |
334 | } | 347 | } |
335 | } | 348 | } |
336 | 349 | ||
337 | 350 | ||
338 | Event *CalendarLocal::event( const QString &uid ) | 351 | Event *CalendarLocal::event( const QString &uid ) |
339 | { | 352 | { |
340 | Event *event; | 353 | Event *event; |
341 | Event *retVal = 0; | 354 | Event *retVal = 0; |
342 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 355 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
343 | if ( event->calEnabled() && event->uid() == uid ) { | 356 | if ( event->calEnabled() && event->uid() == uid ) { |
344 | if ( retVal ) { | 357 | if ( retVal ) { |
345 | if ( retVal->calID() > event->calID() ) { | 358 | if ( retVal->calID() > event->calID() ) { |
346 | retVal = event; | 359 | retVal = event; |
347 | } | 360 | } |
348 | } else { | 361 | } else { |
349 | retVal = event; | 362 | retVal = event; |
350 | } | 363 | } |
351 | } | 364 | } |
352 | } | 365 | } |
353 | return retVal; | 366 | return retVal; |
354 | } | 367 | } |
355 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 368 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
356 | { | 369 | { |
357 | Todo * eve; | 370 | Todo * eve; |
358 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 371 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
359 | if ( *eve == *todo ) { | 372 | if ( *eve == *todo ) { |
360 | //qDebug("duplicate todo found! not inserted! "); | 373 | //qDebug("duplicate todo found! not inserted! "); |
361 | return false; | 374 | return false; |
362 | } | 375 | } |
363 | } | 376 | } |
364 | return addTodo( todo ); | 377 | return addTodo( todo ); |
365 | } | 378 | } |
366 | bool CalendarLocal::addTodo( Todo *todo ) | 379 | bool CalendarLocal::addTodo( Todo *todo ) |
367 | { | 380 | { |
368 | mTodoList.append( todo ); | 381 | mTodoList.append( todo ); |
369 | 382 | ||
370 | todo->registerObserver( this ); | 383 | todo->registerObserver( this ); |
371 | 384 | ||
372 | // Set up subtask relations | 385 | // Set up subtask relations |
373 | setupRelations( todo ); | 386 | setupRelations( todo ); |
374 | 387 | ||
375 | setModified( true ); | 388 | setModified( true ); |
376 | if ( todo->calID() == 0 ) | 389 | if ( todo->calID() == 0 ) |
377 | todo->setCalID( mDefaultCalendar ); | 390 | todo->setCalID( mDefaultCalendar ); |
378 | todo->setCalEnabled( true ); | 391 | todo->setCalEnabled( true ); |
379 | return true; | 392 | return true; |
380 | } | 393 | } |
381 | 394 | ||
382 | void CalendarLocal::deleteTodo( Todo *todo ) | 395 | void CalendarLocal::deleteTodo( Todo *todo ) |
383 | { | 396 | { |
384 | // Handle orphaned children | 397 | // Handle orphaned children |
385 | if ( mUndoIncidence ) delete mUndoIncidence; | 398 | clearUndo(); |
386 | removeRelations( todo ); | 399 | removeRelations( todo ); |
387 | mUndoIncidence = todo->clone(); | 400 | mUndoIncidence = todo; |
388 | 401 | ||
389 | if ( mTodoList.removeRef( todo ) ) { | 402 | if ( mTodoList.removeRef( todo ) ) { |
390 | setModified( true ); | 403 | setModified( true ); |
391 | } | 404 | } |
392 | } | 405 | } |
393 | 406 | ||
394 | QPtrList<Todo> CalendarLocal::rawTodos() | 407 | QPtrList<Todo> CalendarLocal::rawTodos() |
395 | { | 408 | { |
396 | QPtrList<Todo> el; | 409 | QPtrList<Todo> el; |
397 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 410 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
398 | if ( it->calEnabled() ) el.append( it ); | 411 | if ( it->calEnabled() ) el.append( it ); |
399 | return el; | 412 | return el; |
400 | } | 413 | } |
401 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 414 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
402 | { | 415 | { |
403 | Todo *todo; | 416 | Todo *todo; |
404 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 417 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
405 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 418 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
406 | } | 419 | } |
407 | 420 | ||
408 | return 0; | 421 | return 0; |
409 | } | 422 | } |
410 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 423 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
411 | { | 424 | { |
412 | QPtrList<Incidence> all = rawIncidences() ; | 425 | QPtrList<Incidence> all = rawIncidences() ; |
413 | Incidence *inc; | 426 | Incidence *inc; |
414 | for ( inc = all.first(); inc; inc = all.next() ) { | 427 | for ( inc = all.first(); inc; inc = all.next() ) { |
415 | inc->removeID( syncProfile ); | 428 | inc->removeID( syncProfile ); |
416 | } | 429 | } |
417 | if ( syncProfile.isEmpty() ) { | 430 | if ( syncProfile.isEmpty() ) { |
418 | QPtrList<Event> el; | 431 | QPtrList<Event> el; |
419 | Event *todo; | 432 | Event *todo; |
420 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 433 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
421 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 434 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
422 | el.append( todo ); | 435 | el.append( todo ); |
423 | } | 436 | } |
424 | for ( todo = el.first(); todo; todo = el.next() ) { | 437 | for ( todo = el.first(); todo; todo = el.next() ) { |
425 | deleteIncidence ( todo ); | 438 | deleteIncidence ( todo ); |
426 | } | 439 | } |
427 | } else { | 440 | } else { |
428 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 441 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
429 | if ( lse ) | 442 | if ( lse ) |
430 | deleteIncidence ( lse ); | 443 | deleteIncidence ( lse ); |
431 | } | 444 | } |
432 | } | 445 | } |
433 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 446 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
434 | { | 447 | { |
435 | QPtrList<Event> el; | 448 | QPtrList<Event> el; |
436 | Event *todo; | 449 | Event *todo; |
437 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 450 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
438 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 451 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
439 | if ( todo->summary().left(3) == "E: " ) | 452 | if ( todo->summary().left(3) == "E: " ) |
440 | el.append( todo ); | 453 | el.append( todo ); |
441 | } | 454 | } |
442 | 455 | ||
443 | return el; | 456 | return el; |
444 | 457 | ||
445 | } | 458 | } |
446 | Event *CalendarLocal::event( QString syncProf, QString id ) | 459 | Event *CalendarLocal::event( QString syncProf, QString id ) |
447 | { | 460 | { |
448 | Event *todo; | 461 | Event *todo; |
449 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 462 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
450 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 463 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
451 | } | 464 | } |
452 | 465 | ||
453 | return 0; | 466 | return 0; |
454 | } | 467 | } |
455 | Todo *CalendarLocal::todo( const QString &uid ) | 468 | Todo *CalendarLocal::todo( const QString &uid ) |
456 | { | 469 | { |
457 | Todo *todo;; | 470 | Todo *todo;; |
458 | Todo *retVal = 0; | 471 | Todo *retVal = 0; |
459 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 472 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
460 | if ( todo->calEnabled() && todo->uid() == uid ) { | 473 | if ( todo->calEnabled() && todo->uid() == uid ) { |
461 | if ( retVal ) { | 474 | if ( retVal ) { |
462 | if ( retVal->calID() > todo->calID() ) { | 475 | if ( retVal->calID() > todo->calID() ) { |
463 | retVal = todo; | 476 | retVal = todo; |
464 | } | 477 | } |
465 | } else { | 478 | } else { |
466 | retVal = todo; | 479 | retVal = todo; |
467 | } | 480 | } |
468 | } | 481 | } |
469 | } | 482 | } |
470 | return retVal; | 483 | return retVal; |
471 | } | 484 | } |
472 | QString CalendarLocal::nextSummary() const | 485 | QString CalendarLocal::nextSummary() const |
473 | { | 486 | { |
474 | return mNextSummary; | 487 | return mNextSummary; |
475 | } | 488 | } |
476 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 489 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
477 | { | 490 | { |
478 | return mNextAlarmEventDateTime; | 491 | return mNextAlarmEventDateTime; |
479 | } | 492 | } |
480 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 493 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
481 | { | 494 | { |
482 | //mNextAlarmIncidence | 495 | //mNextAlarmIncidence |
483 | //mNextAlarmDateTime | 496 | //mNextAlarmDateTime |
@@ -793,233 +806,231 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | |||
793 | if ( event->doesRecur() ) { | 806 | if ( event->doesRecur() ) { |
794 | QDate rStart = event->dtStart().date(); | 807 | QDate rStart = event->dtStart().date(); |
795 | bool found = false; | 808 | bool found = false; |
796 | if ( inclusive ) { | 809 | if ( inclusive ) { |
797 | if ( rStart >= start && rStart <= end ) { | 810 | if ( rStart >= start && rStart <= end ) { |
798 | // Start date of event is in range. Now check for end date. | 811 | // Start date of event is in range. Now check for end date. |
799 | // if duration is negative, event recurs forever, so do not include it. | 812 | // if duration is negative, event recurs forever, so do not include it. |
800 | if ( event->recurrence()->duration() == 0 ) { // End date set | 813 | if ( event->recurrence()->duration() == 0 ) { // End date set |
801 | QDate rEnd = event->recurrence()->endDate(); | 814 | QDate rEnd = event->recurrence()->endDate(); |
802 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 815 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
803 | found = true; | 816 | found = true; |
804 | } | 817 | } |
805 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 818 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
806 | // TODO: Calculate end date from duration. Should be done in Event | 819 | // TODO: Calculate end date from duration. Should be done in Event |
807 | // For now exclude all events with a duration. | 820 | // For now exclude all events with a duration. |
808 | } | 821 | } |
809 | } | 822 | } |
810 | } else { | 823 | } else { |
811 | bool founOne; | 824 | bool founOne; |
812 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 825 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
813 | if ( founOne ) { | 826 | if ( founOne ) { |
814 | if ( next <= end ) { | 827 | if ( next <= end ) { |
815 | found = true; | 828 | found = true; |
816 | } | 829 | } |
817 | } | 830 | } |
818 | 831 | ||
819 | /* | 832 | /* |
820 | // crap !!! | 833 | // crap !!! |
821 | if ( rStart <= end ) { // Start date not after range | 834 | if ( rStart <= end ) { // Start date not after range |
822 | if ( rStart >= start ) { // Start date within range | 835 | if ( rStart >= start ) { // Start date within range |
823 | found = true; | 836 | found = true; |
824 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 837 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
825 | found = true; | 838 | found = true; |
826 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 839 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
827 | QDate rEnd = event->recurrence()->endDate(); | 840 | QDate rEnd = event->recurrence()->endDate(); |
828 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 841 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
829 | found = true; | 842 | found = true; |
830 | } | 843 | } |
831 | } else { // Duration set | 844 | } else { // Duration set |
832 | // TODO: Calculate end date from duration. Should be done in Event | 845 | // TODO: Calculate end date from duration. Should be done in Event |
833 | // For now include all events with a duration. | 846 | // For now include all events with a duration. |
834 | found = true; | 847 | found = true; |
835 | } | 848 | } |
836 | } | 849 | } |
837 | */ | 850 | */ |
838 | 851 | ||
839 | } | 852 | } |
840 | 853 | ||
841 | if ( found ) eventList.append( event ); | 854 | if ( found ) eventList.append( event ); |
842 | } else { | 855 | } else { |
843 | QDate s = event->dtStart().date(); | 856 | QDate s = event->dtStart().date(); |
844 | QDate e = event->dtEnd().date(); | 857 | QDate e = event->dtEnd().date(); |
845 | 858 | ||
846 | if ( inclusive ) { | 859 | if ( inclusive ) { |
847 | if ( s >= start && e <= end ) { | 860 | if ( s >= start && e <= end ) { |
848 | eventList.append( event ); | 861 | eventList.append( event ); |
849 | } | 862 | } |
850 | } else { | 863 | } else { |
851 | if ( ( e >= start && s <= end ) ) { | 864 | if ( ( e >= start && s <= end ) ) { |
852 | eventList.append( event ); | 865 | eventList.append( event ); |
853 | } | 866 | } |
854 | } | 867 | } |
855 | } | 868 | } |
856 | } | 869 | } |
857 | 870 | ||
858 | return eventList; | 871 | return eventList; |
859 | } | 872 | } |
860 | 873 | ||
861 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 874 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
862 | { | 875 | { |
863 | return rawEventsForDate( qdt.date() ); | 876 | return rawEventsForDate( qdt.date() ); |
864 | } | 877 | } |
865 | 878 | ||
866 | QPtrList<Event> CalendarLocal::rawEvents() | 879 | QPtrList<Event> CalendarLocal::rawEvents() |
867 | { | 880 | { |
868 | QPtrList<Event> el; | 881 | QPtrList<Event> el; |
869 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 882 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
870 | if ( it->calEnabled() ) el.append( it ); | 883 | if ( it->calEnabled() ) el.append( it ); |
871 | return el; | 884 | return el; |
872 | } | 885 | } |
873 | 886 | ||
874 | bool CalendarLocal::addJournal(Journal *journal) | 887 | bool CalendarLocal::addJournal(Journal *journal) |
875 | { | 888 | { |
876 | mJournalList.append(journal); | 889 | mJournalList.append(journal); |
877 | 890 | ||
878 | journal->registerObserver( this ); | 891 | journal->registerObserver( this ); |
879 | 892 | ||
880 | setModified( true ); | 893 | setModified( true ); |
881 | if ( journal->calID() == 0 ) | 894 | if ( journal->calID() == 0 ) |
882 | journal->setCalID( mDefaultCalendar ); | 895 | journal->setCalID( mDefaultCalendar ); |
883 | journal->setCalEnabled( true ); | 896 | journal->setCalEnabled( true ); |
884 | return true; | 897 | return true; |
885 | } | 898 | } |
886 | 899 | ||
887 | void CalendarLocal::deleteJournal( Journal *journal ) | 900 | void CalendarLocal::deleteJournal( Journal *journal ) |
888 | { | 901 | { |
889 | if ( mUndoIncidence ) delete mUndoIncidence; | 902 | clearUndo(); |
890 | mUndoIncidence = journal->clone(); | 903 | mUndoIncidence = journal; |
891 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | ||
892 | if ( mJournalList.removeRef(journal) ) { | 904 | if ( mJournalList.removeRef(journal) ) { |
893 | setModified( true ); | 905 | setModified( true ); |
894 | } | 906 | } |
895 | } | 907 | } |
896 | 908 | ||
897 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 909 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
898 | { | 910 | { |
899 | QPtrList<Journal> el; | 911 | QPtrList<Journal> el; |
900 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 912 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
901 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); | 913 | if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); |
902 | return el; | 914 | return el; |
903 | } | 915 | } |
904 | Journal *CalendarLocal::journal( const QDate &date ) | 916 | Journal *CalendarLocal::journal( const QDate &date ) |
905 | { | 917 | { |
906 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 918 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
907 | 919 | ||
908 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 920 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
909 | if ( it->calEnabled() && it->dtStart().date() == date ) | 921 | if ( it->calEnabled() && it->dtStart().date() == date ) |
910 | return it; | 922 | return it; |
911 | 923 | ||
912 | return 0; | 924 | return 0; |
913 | } | 925 | } |
914 | 926 | ||
915 | Journal *CalendarLocal::journal( const QString &uid ) | 927 | Journal *CalendarLocal::journal( const QString &uid ) |
916 | { | 928 | { |
917 | Journal * retVal = 0; | 929 | Journal * retVal = 0; |
918 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 930 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
919 | if ( it->calEnabled() && it->uid() == uid ) { | 931 | if ( it->calEnabled() && it->uid() == uid ) { |
920 | if ( retVal ) { | 932 | if ( retVal ) { |
921 | if ( retVal->calID() > it->calID() ) { | 933 | if ( retVal->calID() > it->calID() ) { |
922 | retVal = it; | 934 | retVal = it; |
923 | } | 935 | } |
924 | } else { | 936 | } else { |
925 | retVal = it; | 937 | retVal = it; |
926 | } | 938 | } |
927 | } | 939 | } |
928 | return retVal; | 940 | return retVal; |
929 | } | 941 | } |
930 | 942 | ||
931 | QPtrList<Journal> CalendarLocal::journals() | 943 | QPtrList<Journal> CalendarLocal::journals() |
932 | { | 944 | { |
933 | QPtrList<Journal> el; | 945 | QPtrList<Journal> el; |
934 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 946 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
935 | if ( it->calEnabled() ) el.append( it ); | 947 | if ( it->calEnabled() ) el.append( it ); |
936 | return el; | 948 | return el; |
937 | } | 949 | } |
938 | void CalendarLocal::setCalendarRemove( int id ) | 950 | void CalendarLocal::setCalendarRemove( int id ) |
939 | { | 951 | { |
940 | 952 | ||
941 | { | 953 | { |
942 | QPtrList<Event> EventList = mEventList; | 954 | QPtrList<Event> EventList = mEventList; |
943 | Event * ev = EventList.first(); | 955 | Event * ev = EventList.first(); |
944 | while ( ev ) { | 956 | while ( ev ) { |
945 | if ( ev->calID() == id ) | 957 | if ( ev->calID() == id ) |
946 | deleteEvent( ev ); | 958 | deleteEvent( ev ); |
947 | ev = EventList.next(); | 959 | ev = EventList.next(); |
948 | } | 960 | } |
949 | } | 961 | } |
950 | { | 962 | { |
951 | 963 | ||
952 | QPtrList<Todo> TodoList = mTodoList; | 964 | QPtrList<Todo> TodoList = mTodoList; |
953 | Todo * ev = TodoList.first(); | 965 | Todo * ev = TodoList.first(); |
954 | while ( ev ) { | 966 | while ( ev ) { |
955 | if ( ev->calID() == id ) | 967 | if ( ev->calID() == id ) |
956 | deleteTodo( ev ); | 968 | deleteTodo( ev ); |
957 | ev = TodoList.next(); | 969 | ev = TodoList.next(); |
958 | } | 970 | } |
959 | } | 971 | } |
960 | { | 972 | { |
961 | QPtrList<Journal> JournalList = mJournalList; | 973 | QPtrList<Journal> JournalList = mJournalList; |
962 | Journal * ev = JournalList.first(); | 974 | Journal * ev = JournalList.first(); |
963 | while ( ev ) { | 975 | while ( ev ) { |
964 | if ( ev->calID() == id ) | 976 | if ( ev->calID() == id ) |
965 | deleteJournal( ev ); | 977 | deleteJournal( ev ); |
966 | ev = JournalList.next(); | 978 | ev = JournalList.next(); |
967 | } | 979 | } |
968 | } | 980 | } |
969 | 981 | ||
970 | if ( mUndoIncidence ) delete mUndoIncidence; | 982 | clearUndo(); |
971 | mUndoIncidence = 0; | ||
972 | 983 | ||
973 | } | 984 | } |
974 | 985 | ||
975 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 986 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
976 | { | 987 | { |
977 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 988 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
978 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 989 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
979 | 990 | ||
980 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 991 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
981 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 992 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
982 | 993 | ||
983 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 994 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
984 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 995 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
985 | 996 | ||
986 | } | 997 | } |
987 | 998 | ||
988 | void CalendarLocal::setReadOnly( int id, bool enable ) | 999 | void CalendarLocal::setReadOnly( int id, bool enable ) |
989 | { | 1000 | { |
990 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1001 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
991 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1002 | if ( it->calID() == id ) it->setReadOnly( enable ); |
992 | 1003 | ||
993 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1004 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
994 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1005 | if ( it->calID() == id ) it->setReadOnly( enable ); |
995 | 1006 | ||
996 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1007 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
997 | if ( it->calID() == id ) it->setReadOnly( enable ); | 1008 | if ( it->calID() == id ) it->setReadOnly( enable ); |
998 | 1009 | ||
999 | } | 1010 | } |
1000 | 1011 | ||
1001 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 1012 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
1002 | { | 1013 | { |
1003 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1014 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1004 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1015 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1005 | 1016 | ||
1006 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1017 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1007 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1018 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1008 | 1019 | ||
1009 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1020 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1010 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 1021 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
1011 | reInitAlarmSettings(); | 1022 | reInitAlarmSettings(); |
1012 | 1023 | ||
1013 | } | 1024 | } |
1014 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 1025 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
1015 | { | 1026 | { |
1016 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 1027 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
1017 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 1028 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
1018 | 1029 | ||
1019 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 1030 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
1020 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1031 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1021 | 1032 | ||
1022 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 1033 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
1023 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 1034 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
1024 | 1035 | ||
1025 | } | 1036 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a7a85c8..ae7e30c 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,167 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | void addCalendar( Calendar* ); | 46 | void addCalendar( Calendar* ); |
47 | bool addCalendarFile( QString name, int id ); | 47 | bool addCalendarFile( QString name, int id ); |
48 | bool mergeCalendarFile( QString name ); | 48 | bool mergeCalendarFile( QString name ); |
49 | bool mergeCalendar( Calendar* cal ); | 49 | bool mergeCalendar( Calendar* cal ); |
50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); |
51 | void setSyncEventsReadOnly(); | 51 | void setSyncEventsReadOnly(); |
52 | void stopAllTodos(); | 52 | void stopAllTodos(); |
53 | /** | 53 | /** |
54 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 54 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
55 | calendar. Any information already present is lost. | 55 | calendar. Any information already present is lost. |
56 | @return true, if successfull, false on error. | 56 | @return true, if successfull, false on error. |
57 | @param fileName the name of the calendar on disk. | 57 | @param fileName the name of the calendar on disk. |
58 | */ | 58 | */ |
59 | bool load( const QString &fileName ); | 59 | bool load( const QString &fileName ); |
60 | /** | 60 | /** |
61 | Writes out the calendar to disk in the specified \a format. | 61 | Writes out the calendar to disk in the specified \a format. |
62 | CalendarLocal takes ownership of the CalFormat object. | 62 | CalendarLocal takes ownership of the CalFormat object. |
63 | @return true, if successfull, false on error. | 63 | @return true, if successfull, false on error. |
64 | @param fileName the name of the file | 64 | @param fileName the name of the file |
65 | */ | 65 | */ |
66 | bool save( const QString &fileName, CalFormat *format = 0 ); | 66 | bool save( const QString &fileName, CalFormat *format = 0 ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | Clears out the current calendar, freeing all used memory etc. etc. | 69 | Clears out the current calendar, freeing all used memory etc. etc. |
70 | */ | 70 | */ |
71 | void close(); | 71 | void close(); |
72 | void clearUndo(); | ||
72 | 73 | ||
73 | void save() {} | 74 | void save() {} |
74 | 75 | ||
75 | /** | 76 | /** |
76 | Add Event to calendar. | 77 | Add Event to calendar. |
77 | */ | 78 | */ |
78 | void removeSyncInfo( QString syncProfile); | 79 | void removeSyncInfo( QString syncProfile); |
79 | bool addAnniversaryNoDup( Event *event ); | 80 | bool addAnniversaryNoDup( Event *event ); |
80 | bool addEventNoDup( Event *event ); | 81 | bool addEventNoDup( Event *event ); |
81 | bool addEvent( Event *event ); | 82 | bool addEvent( Event *event ); |
82 | /** | 83 | /** |
83 | Deletes an event from this calendar. | 84 | Deletes an event from this calendar. |
84 | */ | 85 | */ |
85 | void deleteEvent( Event *event ); | 86 | void deleteEvent( Event *event ); |
86 | 87 | ||
87 | /** | 88 | /** |
88 | Retrieves an event on the basis of the unique string ID. | 89 | Retrieves an event on the basis of the unique string ID. |
89 | */ | 90 | */ |
90 | Event *event( const QString &uid ); | 91 | Event *event( const QString &uid ); |
91 | /** | 92 | /** |
92 | Return unfiltered list of all events in calendar. | 93 | Return unfiltered list of all events in calendar. |
93 | */ | 94 | */ |
94 | QPtrList<Event> rawEvents(); | 95 | QPtrList<Event> rawEvents(); |
95 | QPtrList<Event> getExternLastSyncEvents(); | 96 | QPtrList<Event> getExternLastSyncEvents(); |
96 | /** | 97 | /** |
97 | Add a todo to the todolist. | 98 | Add a todo to the todolist. |
98 | */ | 99 | */ |
99 | bool addTodo( Todo *todo ); | 100 | bool addTodo( Todo *todo ); |
100 | bool addTodoNoDup( Todo *todo ); | 101 | bool addTodoNoDup( Todo *todo ); |
101 | /** | 102 | /** |
102 | Remove a todo from the todolist. | 103 | Remove a todo from the todolist. |
103 | */ | 104 | */ |
104 | void deleteTodo( Todo * ); | 105 | void deleteTodo( Todo * ); |
105 | /** | 106 | /** |
106 | Searches todolist for an event with this unique string identifier, | 107 | Searches todolist for an event with this unique string identifier, |
107 | returns a pointer or null. | 108 | returns a pointer or null. |
108 | */ | 109 | */ |
109 | Todo *todo( const QString &uid ); | 110 | Todo *todo( const QString &uid ); |
110 | /** | 111 | /** |
111 | Return list of all todos. | 112 | Return list of all todos. |
112 | */ | 113 | */ |
113 | QPtrList<Todo> rawTodos(); | 114 | QPtrList<Todo> rawTodos(); |
114 | /** | 115 | /** |
115 | Returns list of todos due on the specified date. | 116 | Returns list of todos due on the specified date. |
116 | */ | 117 | */ |
117 | QPtrList<Todo> todos( const QDate &date ); | 118 | QPtrList<Todo> todos( const QDate &date ); |
118 | /** | 119 | /** |
119 | Return list of all todos. | 120 | Return list of all todos. |
120 | 121 | ||
121 | Workaround because compiler does not recognize function of base class. | 122 | Workaround because compiler does not recognize function of base class. |
122 | */ | 123 | */ |
123 | QPtrList<Todo> todos() { return Calendar::todos(); } | 124 | QPtrList<Todo> todos() { return Calendar::todos(); } |
124 | 125 | ||
125 | /** | 126 | /** |
126 | Add a Journal entry to calendar. | 127 | Add a Journal entry to calendar. |
127 | */ | 128 | */ |
128 | bool addJournal( Journal * ); | 129 | bool addJournal( Journal * ); |
129 | /** | 130 | /** |
130 | Remove a Journal from the calendar. | 131 | Remove a Journal from the calendar. |
131 | */ | 132 | */ |
132 | void deleteJournal( Journal * ); | 133 | void deleteJournal( Journal * ); |
133 | /** | 134 | /** |
134 | Return Journal for given date. | 135 | Return Journal for given date. |
135 | */ | 136 | */ |
136 | Journal *journal( const QDate & ); | 137 | Journal *journal( const QDate & ); |
137 | QPtrList<Journal> journals4Date( const QDate & ); | 138 | QPtrList<Journal> journals4Date( const QDate & ); |
138 | /** | 139 | /** |
139 | Return Journal with given UID. | 140 | Return Journal with given UID. |
140 | */ | 141 | */ |
141 | Journal *journal( const QString &uid ); | 142 | Journal *journal( const QString &uid ); |
142 | /** | 143 | /** |
143 | Return list of all Journals stored in calendar. | 144 | Return list of all Journals stored in calendar. |
144 | */ | 145 | */ |
145 | QPtrList<Journal> journals(); | 146 | QPtrList<Journal> journals(); |
146 | 147 | ||
147 | /** | 148 | /** |
148 | Return all alarms, which ocur in the given time interval. | 149 | Return all alarms, which ocur in the given time interval. |
149 | */ | 150 | */ |
150 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 151 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
151 | 152 | ||
152 | /** | 153 | /** |
153 | Return all alarms, which ocur before given date. | 154 | Return all alarms, which ocur before given date. |
154 | */ | 155 | */ |
155 | Alarm::List alarmsTo( const QDateTime &to ); | 156 | Alarm::List alarmsTo( const QDateTime &to ); |
156 | 157 | ||
157 | QDateTime nextAlarm( int daysTo ) ; | 158 | QDateTime nextAlarm( int daysTo ) ; |
158 | QDateTime nextAlarmEventDateTime() const; | 159 | QDateTime nextAlarmEventDateTime() const; |
159 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 160 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
160 | void registerAlarm(); | 161 | void registerAlarm(); |
161 | void deRegisterAlarm(); | 162 | void deRegisterAlarm(); |
162 | QString getAlarmNotification(); | 163 | QString getAlarmNotification(); |
163 | QString nextSummary() const ; | 164 | QString nextSummary() const ; |
164 | /** | 165 | /** |
165 | This method should be called whenever a Event is modified directly | 166 | This method should be called whenever a Event is modified directly |
166 | via it's pointer. It makes sure that the calendar is internally | 167 | via it's pointer. It makes sure that the calendar is internally |
167 | consistent. | 168 | consistent. |
diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp index c4e4474..328db46 100644 --- a/libkcal/journal.cpp +++ b/libkcal/journal.cpp | |||
@@ -1,51 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "journal.h" | 21 | #include "journal.h" |
22 | 22 | ||
23 | using namespace KCal; | 23 | using namespace KCal; |
24 | 24 | ||
25 | Journal::Journal() | 25 | Journal::Journal() |
26 | { | 26 | { |
27 | qDebug("New JJJ "); | 27 | |
28 | } | 28 | } |
29 | 29 | ||
30 | Journal::~Journal() | 30 | Journal::~Journal() |
31 | { | 31 | { |
32 | qDebug("delete JJJ "); | 32 | |
33 | } | 33 | } |
34 | 34 | ||
35 | Incidence *Journal::clone() | 35 | Incidence *Journal::clone() |
36 | { | 36 | { |
37 | return new Journal(*this); | 37 | return new Journal(*this); |
38 | } | 38 | } |
39 | 39 | ||
40 | 40 | ||
41 | bool KCal::operator==( const Journal& j1, const Journal& j2 ) | 41 | bool KCal::operator==( const Journal& j1, const Journal& j2 ) |
42 | { | 42 | { |
43 | return operator==( (const Incidence&)j1, (const Incidence&)j2 ); | 43 | return operator==( (const Incidence&)j1, (const Incidence&)j2 ); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | QDateTime Journal::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 47 | QDateTime Journal::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
48 | { | 48 | { |
49 | *ok = false; | 49 | *ok = false; |
50 | return QDateTime (); | 50 | return QDateTime (); |
51 | } | 51 | } |