summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp26
-rw-r--r--libkcal/calendarlocal.h1
3 files changed, 28 insertions, 1 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 3f6895d..4b8b3ff 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -226,155 +226,157 @@ public:
226 returns a pointer or null. 226 returns a pointer or null.
227 */ 227 */
228 virtual Todo *todo( const QString &uid ) = 0; 228 virtual Todo *todo( const QString &uid ) = 0;
229 virtual Todo *todo( QString, QString ) = 0; 229 virtual Todo *todo( QString, QString ) = 0;
230 /** 230 /**
231 Returns list of todos due on the specified date. 231 Returns list of todos due on the specified date.
232 */ 232 */
233 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 233 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
234 /** 234 /**
235 Return unfiltered list of todos. 235 Return unfiltered list of todos.
236 */ 236 */
237 virtual QPtrList<Todo> rawTodos() = 0; 237 virtual QPtrList<Todo> rawTodos() = 0;
238 238
239 /** 239 /**
240 Add a Journal entry to calendar. 240 Add a Journal entry to calendar.
241 241
242 @return true on success, false on error. 242 @return true on success, false on error.
243 */ 243 */
244 virtual bool addJournal( Journal * ) = 0; 244 virtual bool addJournal( Journal * ) = 0;
245 /** 245 /**
246 Return Journal for given date. 246 Return Journal for given date.
247 */ 247 */
248 virtual Journal *journal( const QDate & ) = 0; 248 virtual Journal *journal( const QDate & ) = 0;
249 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; 249 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0;
250 /** 250 /**
251 Return Journal with given UID. 251 Return Journal with given UID.
252 */ 252 */
253 virtual Journal *journal( const QString &UID ) = 0; 253 virtual Journal *journal( const QString &UID ) = 0;
254 /** 254 /**
255 Return list of all Journal entries. 255 Return list of all Journal entries.
256 */ 256 */
257 virtual QPtrList<Journal> journals() = 0; 257 virtual QPtrList<Journal> journals() = 0;
258 258
259 /** 259 /**
260 Searches all incidence types for an incidence with this unique 260 Searches all incidence types for an incidence with this unique
261 string identifier, returns a pointer or null. 261 string identifier, returns a pointer or null.
262 */ 262 */
263 Incidence* incidence( const QString&UID ); 263 Incidence* incidence( const QString&UID );
264 264
265 /** 265 /**
266 Setup relations for an incidence. 266 Setup relations for an incidence.
267 */ 267 */
268 virtual void setupRelations( Incidence * ); 268 virtual void setupRelations( Incidence * );
269 /** 269 /**
270 Remove all relations to an incidence 270 Remove all relations to an incidence
271 */ 271 */
272 virtual void removeRelations( Incidence * ); 272 virtual void removeRelations( Incidence * );
273 273
274 /** 274 /**
275 Set calendar filter, which filters events for the events() functions. 275 Set calendar filter, which filters events for the events() functions.
276 The Filter object is owned by the caller. 276 The Filter object is owned by the caller.
277 */ 277 */
278 void setFilter( CalFilter * ); 278 void setFilter( CalFilter * );
279 /** 279 /**
280 Return calendar filter. 280 Return calendar filter.
281 */ 281 */
282 CalFilter *filter(); 282 CalFilter *filter();
283 virtual QDateTime nextAlarm( int daysTo ) = 0; 283 virtual QDateTime nextAlarm( int daysTo ) = 0;
284 virtual QString nextSummary( ) const = 0; 284 virtual QString nextSummary( ) const = 0;
285 virtual void reInitAlarmSettings() = 0; 285 virtual void reInitAlarmSettings() = 0;
286 virtual QDateTime nextAlarmEventDateTime() const = 0; 286 virtual QDateTime nextAlarmEventDateTime() const = 0;
287 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 287 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
288 /** 288 /**
289 Return all alarms, which ocur in the given time interval. 289 Return all alarms, which ocur in the given time interval.
290 */ 290 */
291 virtual Alarm::List alarms( const QDateTime &from, 291 virtual Alarm::List alarms( const QDateTime &from,
292 const QDateTime &to ) = 0; 292 const QDateTime &to ) = 0;
293 293
294 class Observer { 294 class Observer {
295 public: 295 public:
296 virtual void calendarModified( bool, Calendar * ) = 0; 296 virtual void calendarModified( bool, Calendar * ) = 0;
297 }; 297 };
298 298
299 void registerObserver( Observer * ); 299 void registerObserver( Observer * );
300 300
301 void setModified( bool ); 301 void setModified( bool );
302 302
303 /** 303 /**
304 Set product id returned by loadedProductId(). This function is only 304 Set product id returned by loadedProductId(). This function is only
305 useful for the calendar loading code. 305 useful for the calendar loading code.
306 */ 306 */
307 void setLoadedProductId( const QString & ); 307 void setLoadedProductId( const QString & );
308 /** 308 /**
309 Return product id taken from file that has been loaded. Returns 309 Return product id taken from file that has been loaded. Returns
310 QString::null, if no calendar has been loaded. 310 QString::null, if no calendar has been loaded.
311 */ 311 */
312 QString loadedProductId(); 312 QString loadedProductId();
313 int defaultCalendar(); 313 int defaultCalendar();
314 void setDontDeleteIncidencesOnClose (); 314 void setDontDeleteIncidencesOnClose ();
315 public slots: 315 public slots:
316 void setDefaultCalendar( int ); 316 void setDefaultCalendar( int );
317 virtual void setCalendarEnabled( int id, bool enable ) = 0; 317 virtual void setCalendarEnabled( int id, bool enable ) = 0;
318 virtual void setAlarmEnabled( int id, bool enable ) = 0; 318 virtual void setAlarmEnabled( int id, bool enable ) = 0;
319 virtual void setReadOnly( int id, bool enable ) = 0; 319 virtual void setReadOnly( int id, bool enable ) = 0;
320 virtual void setDefaultCalendarEnabledOnly() = 0; 320 virtual void setDefaultCalendarEnabledOnly() = 0;
321 virtual void setCalendarRemove( int id ) = 0; 321 virtual void setCalendarRemove( int id ) = 0;
322 virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0;
323
322 signals: 324 signals:
323 void calendarChanged(); 325 void calendarChanged();
324 void calendarSaved(); 326 void calendarSaved();
325 void calendarLoaded(); 327 void calendarLoaded();
326 void addAlarm(const QDateTime &qdt, const QString &noti ); 328 void addAlarm(const QDateTime &qdt, const QString &noti );
327 void removeAlarm(const QDateTime &qdt, const QString &noti ); 329 void removeAlarm(const QDateTime &qdt, const QString &noti );
328 330
329 protected: 331 protected:
330 /** 332 /**
331 Get unfiltered events, which occur on the given date. 333 Get unfiltered events, which occur on the given date.
332 */ 334 */
333 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 335 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
334 /** 336 /**
335 Get unfiltered events, which occur on the given date. 337 Get unfiltered events, which occur on the given date.
336 */ 338 */
337 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 339 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
338 bool sorted = false ) = 0; 340 bool sorted = false ) = 0;
339 /** 341 /**
340 Get events in a range of dates. If inclusive is set to true, only events 342 Get events in a range of dates. If inclusive is set to true, only events
341 are returned, which are completely included in the range. 343 are returned, which are completely included in the range.
342 */ 344 */
343 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 345 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
344 bool inclusive = false ) = 0; 346 bool inclusive = false ) = 0;
345 347
346 Incidence *mNextAlarmIncidence; 348 Incidence *mNextAlarmIncidence;
347 Incidence *mUndoIncidence; 349 Incidence *mUndoIncidence;
348 int mDefaultCalendar; 350 int mDefaultCalendar;
349 bool mDeleteIncidencesOnClose; 351 bool mDeleteIncidencesOnClose;
350 352
351private: 353private:
352 void init(); 354 void init();
353 355
354 QString mOwner; // who the calendar belongs to 356 QString mOwner; // who the calendar belongs to
355 QString mOwnerEmail; // email address of the owner 357 QString mOwnerEmail; // email address of the owner
356 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 358 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
357 bool mLocalTime; // use local time, not UTC or a time zone 359 bool mLocalTime; // use local time, not UTC or a time zone
358 360
359 361
360 CalFilter *mFilter; 362 CalFilter *mFilter;
361 CalFilter *mDefaultFilter; 363 CalFilter *mDefaultFilter;
362 364
363 365
364 QString mTimeZoneId; 366 QString mTimeZoneId;
365 367
366 Observer *mObserver; 368 Observer *mObserver;
367 bool mNewObserver; 369 bool mNewObserver;
368 370
369 bool mModified; 371 bool mModified;
370 372
371 QString mLoadedProductId; 373 QString mLoadedProductId;
372 374
373 // This list is used to put together related todos 375 // This list is used to put together related todos
374 QDict<Incidence> mOrphans; 376 QDict<Incidence> mOrphans;
375 QDict<Incidence> mOrphanUids; 377 QDict<Incidence> mOrphanUids;
376}; 378};
377 379
378} 380}
379 381
380#endif 382#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 1a1c6be..0ddfeca 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -359,207 +359,231 @@ bool CalendarLocal::addTodoNoDup( Todo *todo )
359 //qDebug("duplicate todo found! not inserted! "); 359 //qDebug("duplicate todo found! not inserted! ");
360 return false; 360 return false;
361 } 361 }
362 } 362 }
363 return addTodo( todo ); 363 return addTodo( todo );
364} 364}
365bool CalendarLocal::addTodo( Todo *todo ) 365bool CalendarLocal::addTodo( Todo *todo )
366{ 366{
367 mTodoList.append( todo ); 367 mTodoList.append( todo );
368 368
369 todo->registerObserver( this ); 369 todo->registerObserver( this );
370 370
371 // Set up subtask relations 371 // Set up subtask relations
372 setupRelations( todo ); 372 setupRelations( todo );
373 373
374 setModified( true ); 374 setModified( true );
375 if ( todo->calID() == 0 ) 375 if ( todo->calID() == 0 )
376 todo->setCalID( mDefaultCalendar ); 376 todo->setCalID( mDefaultCalendar );
377 todo->setCalEnabled( true ); 377 todo->setCalEnabled( true );
378 return true; 378 return true;
379} 379}
380 380
381void CalendarLocal::deleteTodo( Todo *todo ) 381void CalendarLocal::deleteTodo( Todo *todo )
382{ 382{
383 // Handle orphaned children 383 // Handle orphaned children
384 removeRelations( todo ); 384 removeRelations( todo );
385 clearUndo(todo); 385 clearUndo(todo);
386 386
387 if ( mTodoList.removeRef( todo ) ) { 387 if ( mTodoList.removeRef( todo ) ) {
388 setModified( true ); 388 setModified( true );
389 } 389 }
390} 390}
391 391
392QPtrList<Todo> CalendarLocal::rawTodos() 392QPtrList<Todo> CalendarLocal::rawTodos()
393{ 393{
394 QPtrList<Todo> el; 394 QPtrList<Todo> el;
395 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 395 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
396 if ( it->calEnabled() ) el.append( it ); 396 if ( it->calEnabled() ) el.append( it );
397 return el; 397 return el;
398} 398}
399Todo *CalendarLocal::todo( QString syncProf, QString id ) 399Todo *CalendarLocal::todo( QString syncProf, QString id )
400{ 400{
401 Todo *todo; 401 Todo *todo;
402 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 402 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
403 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 403 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
404 } 404 }
405 405
406 return 0; 406 return 0;
407} 407}
408void CalendarLocal::removeSyncInfo( QString syncProfile) 408void CalendarLocal::removeSyncInfo( QString syncProfile)
409{ 409{
410 QPtrList<Incidence> all = rawIncidences() ; 410 QPtrList<Incidence> all = rawIncidences() ;
411 Incidence *inc; 411 Incidence *inc;
412 for ( inc = all.first(); inc; inc = all.next() ) { 412 for ( inc = all.first(); inc; inc = all.next() ) {
413 inc->removeID( syncProfile ); 413 inc->removeID( syncProfile );
414 } 414 }
415 if ( syncProfile.isEmpty() ) { 415 if ( syncProfile.isEmpty() ) {
416 QPtrList<Event> el; 416 QPtrList<Event> el;
417 Event *todo; 417 Event *todo;
418 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 418 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
419 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 419 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
420 el.append( todo ); 420 el.append( todo );
421 } 421 }
422 for ( todo = el.first(); todo; todo = el.next() ) { 422 for ( todo = el.first(); todo; todo = el.next() ) {
423 deleteIncidence ( todo ); 423 deleteIncidence ( todo );
424 } 424 }
425 } else { 425 } else {
426 Event *lse = event( "last-syncEvent-"+ syncProfile); 426 Event *lse = event( "last-syncEvent-"+ syncProfile);
427 if ( lse ) 427 if ( lse )
428 deleteIncidence ( lse ); 428 deleteIncidence ( lse );
429 } 429 }
430} 430}
431QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 431QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
432{ 432{
433 QPtrList<Event> el; 433 QPtrList<Event> el;
434 Event *todo; 434 Event *todo;
435 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 435 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
436 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 436 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
437 if ( todo->summary().left(3) == "E: " ) 437 if ( todo->summary().left(3) == "E: " )
438 el.append( todo ); 438 el.append( todo );
439 } 439 }
440 440
441 return el; 441 return el;
442 442
443} 443}
444Event *CalendarLocal::event( QString syncProf, QString id ) 444Event *CalendarLocal::event( QString syncProf, QString id )
445{ 445{
446 Event *todo; 446 Event *todo;
447 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 447 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
448 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 448 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
449 } 449 }
450 450
451 return 0; 451 return 0;
452} 452}
453Todo *CalendarLocal::todo( const QString &uid ) 453Todo *CalendarLocal::todo( const QString &uid )
454{ 454{
455 Todo *todo;; 455 Todo *todo;
456 Todo *retVal = 0; 456 Todo *retVal = 0;
457 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 457 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
458 if ( todo->calEnabled() && todo->uid() == uid ) { 458 if ( todo->calEnabled() && todo->uid() == uid ) {
459 if ( retVal ) { 459 if ( retVal ) {
460 if ( retVal->calID() > todo->calID() ) { 460 if ( retVal->calID() > todo->calID() ) {
461 retVal = todo; 461 retVal = todo;
462 } 462 }
463 } else { 463 } else {
464 retVal = todo; 464 retVal = todo;
465 } 465 }
466 } 466 }
467 } 467 }
468 return retVal; 468 return retVal;
469} 469}
470void CalendarLocal::getIncidenceCount( int calId, int& events, int & todos, int & journals)
471{
472 events = 0;
473 todos = 0;
474 journals = 0;
475 {
476 Todo *todo;
477 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
478 if ( todo->calID() == calId )
479 ++todos;
480 }
481 }
482 {
483 Event *todo;
484 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
485 if ( todo->calID() == calId )
486 ++events;
487
488 }
489 }
490 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
491 if ( it->calID() == calId ) ++journals;
492
493}
470QString CalendarLocal::nextSummary() const 494QString CalendarLocal::nextSummary() const
471{ 495{
472 return mNextSummary; 496 return mNextSummary;
473} 497}
474QDateTime CalendarLocal::nextAlarmEventDateTime() const 498QDateTime CalendarLocal::nextAlarmEventDateTime() const
475{ 499{
476 return mNextAlarmEventDateTime; 500 return mNextAlarmEventDateTime;
477} 501}
478void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 502void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
479{ 503{
480 //mNextAlarmIncidence 504 //mNextAlarmIncidence
481 //mNextAlarmDateTime 505 //mNextAlarmDateTime
482 //return mNextSummary; 506 //return mNextSummary;
483 //return mNextAlarmEventDateTime; 507 //return mNextAlarmEventDateTime;
484 bool newNextAlarm = false; 508 bool newNextAlarm = false;
485 bool computeNextAlarm = false; 509 bool computeNextAlarm = false;
486 bool ok; 510 bool ok;
487 int offset; 511 int offset;
488 QDateTime nextA; 512 QDateTime nextA;
489 // QString nextSum; 513 // QString nextSum;
490 //QDateTime nextEvent; 514 //QDateTime nextEvent;
491 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 515 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
492 computeNextAlarm = true; 516 computeNextAlarm = true;
493 } else { 517 } else {
494 if ( ! deleted ) { 518 if ( ! deleted ) {
495 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 519 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
496 if ( ok ) { 520 if ( ok ) {
497 if ( nextA < mNextAlarmDateTime ) { 521 if ( nextA < mNextAlarmDateTime ) {
498 deRegisterAlarm(); 522 deRegisterAlarm();
499 mNextAlarmDateTime = nextA; 523 mNextAlarmDateTime = nextA;
500 mNextSummary = incidence->summary(); 524 mNextSummary = incidence->summary();
501 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 525 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
502 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 526 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
503 newNextAlarm = true; 527 newNextAlarm = true;
504 mNextAlarmIncidence = incidence; 528 mNextAlarmIncidence = incidence;
505 } else { 529 } else {
506 if ( incidence == mNextAlarmIncidence ) { 530 if ( incidence == mNextAlarmIncidence ) {
507 computeNextAlarm = true; 531 computeNextAlarm = true;
508 } 532 }
509 } 533 }
510 } else { 534 } else {
511 if ( mNextAlarmIncidence == incidence ) { 535 if ( mNextAlarmIncidence == incidence ) {
512 computeNextAlarm = true; 536 computeNextAlarm = true;
513 } 537 }
514 } 538 }
515 } else { // deleted 539 } else { // deleted
516 if ( incidence == mNextAlarmIncidence ) { 540 if ( incidence == mNextAlarmIncidence ) {
517 computeNextAlarm = true; 541 computeNextAlarm = true;
518 } 542 }
519 } 543 }
520 } 544 }
521 if ( computeNextAlarm ) { 545 if ( computeNextAlarm ) {
522 deRegisterAlarm(); 546 deRegisterAlarm();
523 nextA = nextAlarm( 1000 ); 547 nextA = nextAlarm( 1000 );
524 if (! mNextAlarmIncidence ) { 548 if (! mNextAlarmIncidence ) {
525 return; 549 return;
526 } 550 }
527 newNextAlarm = true; 551 newNextAlarm = true;
528 } 552 }
529 if ( newNextAlarm ) 553 if ( newNextAlarm )
530 registerAlarm(); 554 registerAlarm();
531} 555}
532QString CalendarLocal:: getAlarmNotification() 556QString CalendarLocal:: getAlarmNotification()
533{ 557{
534 QString ret; 558 QString ret;
535 // this should not happen 559 // this should not happen
536 if (! mNextAlarmIncidence ) 560 if (! mNextAlarmIncidence )
537 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 561 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
538 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 562 Alarm* alarm = mNextAlarmIncidence->alarms().first();
539 if ( alarm->type() == Alarm::Procedure ) { 563 if ( alarm->type() == Alarm::Procedure ) {
540 ret = "proc_alarm" + alarm->programFile()+"+++"; 564 ret = "proc_alarm" + alarm->programFile()+"+++";
541 } else { 565 } else {
542 ret = "audio_alarm" +alarm->audioFile() +"+++"; 566 ret = "audio_alarm" +alarm->audioFile() +"+++";
543 } 567 }
544 ret += "cal_alarm"+ mNextSummary.left( 25 ); 568 ret += "cal_alarm"+ mNextSummary.left( 25 );
545 if ( mNextSummary.length() > 25 ) 569 if ( mNextSummary.length() > 25 )
546 ret += "\n" + mNextSummary.mid(25, 25 ); 570 ret += "\n" + mNextSummary.mid(25, 25 );
547 ret+= "\n"+mNextAlarmEventDateTimeString; 571 ret+= "\n"+mNextAlarmEventDateTimeString;
548 return ret; 572 return ret;
549} 573}
550void CalendarLocal::registerAlarm() 574void CalendarLocal::registerAlarm()
551{ 575{
552 mLastAlarmNotificationString = getAlarmNotification(); 576 mLastAlarmNotificationString = getAlarmNotification();
553 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 577 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
554 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 578 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
555// #ifndef DESKTOP_VERSION 579// #ifndef DESKTOP_VERSION
556// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 580// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
557// #endif 581// #endif
558} 582}
559void CalendarLocal::deRegisterAlarm() 583void CalendarLocal::deRegisterAlarm()
560{ 584{
561 if ( mLastAlarmNotificationString.isNull() ) 585 if ( mLastAlarmNotificationString.isNull() )
562 return; 586 return;
563 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 587 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
564 588
565 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 589 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a7a85c8..ca0bd98 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -92,139 +92,140 @@ class CalendarLocal : public Calendar
92 Return unfiltered list of all events in calendar. 92 Return unfiltered list of all events in calendar.
93 */ 93 */
94 QPtrList<Event> rawEvents(); 94 QPtrList<Event> rawEvents();
95 QPtrList<Event> getExternLastSyncEvents(); 95 QPtrList<Event> getExternLastSyncEvents();
96 /** 96 /**
97 Add a todo to the todolist. 97 Add a todo to the todolist.
98 */ 98 */
99 bool addTodo( Todo *todo ); 99 bool addTodo( Todo *todo );
100 bool addTodoNoDup( Todo *todo ); 100 bool addTodoNoDup( Todo *todo );
101 /** 101 /**
102 Remove a todo from the todolist. 102 Remove a todo from the todolist.
103 */ 103 */
104 void deleteTodo( Todo * ); 104 void deleteTodo( Todo * );
105 /** 105 /**
106 Searches todolist for an event with this unique string identifier, 106 Searches todolist for an event with this unique string identifier,
107 returns a pointer or null. 107 returns a pointer or null.
108 */ 108 */
109 Todo *todo( const QString &uid ); 109 Todo *todo( const QString &uid );
110 /** 110 /**
111 Return list of all todos. 111 Return list of all todos.
112 */ 112 */
113 QPtrList<Todo> rawTodos(); 113 QPtrList<Todo> rawTodos();
114 /** 114 /**
115 Returns list of todos due on the specified date. 115 Returns list of todos due on the specified date.
116 */ 116 */
117 QPtrList<Todo> todos( const QDate &date ); 117 QPtrList<Todo> todos( const QDate &date );
118 /** 118 /**
119 Return list of all todos. 119 Return list of all todos.
120 120
121 Workaround because compiler does not recognize function of base class. 121 Workaround because compiler does not recognize function of base class.
122 */ 122 */
123 QPtrList<Todo> todos() { return Calendar::todos(); } 123 QPtrList<Todo> todos() { return Calendar::todos(); }
124 124
125 /** 125 /**
126 Add a Journal entry to calendar. 126 Add a Journal entry to calendar.
127 */ 127 */
128 bool addJournal( Journal * ); 128 bool addJournal( Journal * );
129 /** 129 /**
130 Remove a Journal from the calendar. 130 Remove a Journal from the calendar.
131 */ 131 */
132 void deleteJournal( Journal * ); 132 void deleteJournal( Journal * );
133 /** 133 /**
134 Return Journal for given date. 134 Return Journal for given date.
135 */ 135 */
136 Journal *journal( const QDate & ); 136 Journal *journal( const QDate & );
137 QPtrList<Journal> journals4Date( const QDate & ); 137 QPtrList<Journal> journals4Date( const QDate & );
138 /** 138 /**
139 Return Journal with given UID. 139 Return Journal with given UID.
140 */ 140 */
141 Journal *journal( const QString &uid ); 141 Journal *journal( const QString &uid );
142 /** 142 /**
143 Return list of all Journals stored in calendar. 143 Return list of all Journals stored in calendar.
144 */ 144 */
145 QPtrList<Journal> journals(); 145 QPtrList<Journal> journals();
146 146
147 /** 147 /**
148 Return all alarms, which ocur in the given time interval. 148 Return all alarms, which ocur in the given time interval.
149 */ 149 */
150 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 150 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
151 151
152 /** 152 /**
153 Return all alarms, which ocur before given date. 153 Return all alarms, which ocur before given date.
154 */ 154 */
155 Alarm::List alarmsTo( const QDateTime &to ); 155 Alarm::List alarmsTo( const QDateTime &to );
156 156
157 QDateTime nextAlarm( int daysTo ) ; 157 QDateTime nextAlarm( int daysTo ) ;
158 QDateTime nextAlarmEventDateTime() const; 158 QDateTime nextAlarmEventDateTime() const;
159 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 159 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
160 void registerAlarm(); 160 void registerAlarm();
161 void deRegisterAlarm(); 161 void deRegisterAlarm();
162 QString getAlarmNotification(); 162 QString getAlarmNotification();
163 QString nextSummary() const ; 163 QString nextSummary() const ;
164 /** 164 /**
165 This method should be called whenever a Event is modified directly 165 This method should be called whenever a Event is modified directly
166 via it's pointer. It makes sure that the calendar is internally 166 via it's pointer. It makes sure that the calendar is internally
167 consistent. 167 consistent.
168 */ 168 */
169 void update( IncidenceBase *incidence ); 169 void update( IncidenceBase *incidence );
170 170
171 /** 171 /**
172 Builds and then returns a list of all events that match for the 172 Builds and then returns a list of all events that match for the
173 date specified. useful for dayView, etc. etc. 173 date specified. useful for dayView, etc. etc.
174 */ 174 */
175 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 175 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
176 /** 176 /**
177 Get unfiltered events for date \a qdt. 177 Get unfiltered events for date \a qdt.
178 */ 178 */
179 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 179 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
180 /** 180 /**
181 Get unfiltered events in a range of dates. If inclusive is set to true, 181 Get unfiltered events in a range of dates. If inclusive is set to true,
182 only events are returned, which are completely included in the range. 182 only events are returned, which are completely included in the range.
183 */ 183 */
184 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 184 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
185 bool inclusive = false ); 185 bool inclusive = false );
186 Todo *todo( QString, QString ); 186 Todo *todo( QString, QString );
187 Event *event( QString, QString ); 187 Event *event( QString, QString );
188 void getIncidenceCount( int calId, int& events, int & todos, int & journals);
188 189
189public slots: 190public slots:
190 void setCalendarEnabled( int id, bool enable ); 191 void setCalendarEnabled( int id, bool enable );
191 void setAlarmEnabled( int id, bool enable ); 192 void setAlarmEnabled( int id, bool enable );
192 void setReadOnly( int id, bool enable ); 193 void setReadOnly( int id, bool enable );
193 void setDefaultCalendarEnabledOnly(); 194 void setDefaultCalendarEnabledOnly();
194 void setCalendarRemove( int id ); 195 void setCalendarRemove( int id );
195 196
196 protected: 197 protected:
197 198
198 // Event* mNextAlarmEvent; 199 // Event* mNextAlarmEvent;
199 QString mNextSummary; 200 QString mNextSummary;
200 QString mNextAlarmEventDateTimeString; 201 QString mNextAlarmEventDateTimeString;
201 QString mLastAlarmNotificationString; 202 QString mLastAlarmNotificationString;
202 QDateTime mNextAlarmEventDateTime; 203 QDateTime mNextAlarmEventDateTime;
203 QDateTime mNextAlarmDateTime; 204 QDateTime mNextAlarmDateTime;
204 void reInitAlarmSettings(); 205 void reInitAlarmSettings();
205 206
206 /** Notification function of IncidenceBase::Observer. */ 207 /** Notification function of IncidenceBase::Observer. */
207 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 208 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
208 209
209 /** inserts an event into its "proper place" in the calendar. */ 210 /** inserts an event into its "proper place" in the calendar. */
210 void insertEvent( Event *event ); 211 void insertEvent( Event *event );
211 212
212 /** Append alarms of incidence in interval to list of alarms. */ 213 /** Append alarms of incidence in interval to list of alarms. */
213 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 214 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
214 const QDateTime &from, const QDateTime &to ); 215 const QDateTime &from, const QDateTime &to );
215 216
216 /** Append alarms of recurring events in interval to list of alarms. */ 217 /** Append alarms of recurring events in interval to list of alarms. */
217 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 218 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
218 const QDateTime &from, const QDateTime &to ); 219 const QDateTime &from, const QDateTime &to );
219 220
220 private: 221 private:
221 void init(); 222 void init();
222 223
223 QPtrList<Event> mEventList; 224 QPtrList<Event> mEventList;
224 QPtrList<Todo> mTodoList; 225 QPtrList<Todo> mTodoList;
225 QPtrList<Journal> mJournalList; 226 QPtrList<Journal> mJournalList;
226}; 227};
227 228
228} 229}
229 230
230#endif 231#endif