-rw-r--r-- | library/datebookdb.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp index e4ec2bf..165a637 100644 --- a/library/datebookdb.cpp +++ b/library/datebookdb.cpp | |||
@@ -345,96 +345,99 @@ static bool nextAlarm( const Event &ev, QDateTime& when, int& warn) | |||
345 | when = ralarm; | 345 | when = ralarm; |
346 | warn = ev.alarmTime(); | 346 | warn = ev.alarmTime(); |
347 | } else if ( nextOccurance(ev, now.date().addDays(1), ralarm) ) { | 347 | } else if ( nextOccurance(ev, now.date().addDays(1), ralarm) ) { |
348 | ralarm = ralarm.addSecs( -ev.alarmTime()*60 ); | 348 | ralarm = ralarm.addSecs( -ev.alarmTime()*60 ); |
349 | if ( ralarm > now ) { | 349 | if ( ralarm > now ) { |
350 | when = ralarm; | 350 | when = ralarm; |
351 | warn = ev.alarmTime(); | 351 | warn = ev.alarmTime(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | } else { | 355 | } else { |
356 | warn = ev.alarmTime(); | 356 | warn = ev.alarmTime(); |
357 | when = ev.start().addSecs( -ev.alarmTime()*60 ); | 357 | when = ev.start().addSecs( -ev.alarmTime()*60 ); |
358 | } | 358 | } |
359 | return when > now; | 359 | return when > now; |
360 | } | 360 | } |
361 | 361 | ||
362 | static void addEventAlarm( const Event &ev ) | 362 | static void addEventAlarm( const Event &ev ) |
363 | { | 363 | { |
364 | QDateTime when; | 364 | QDateTime when; |
365 | int warn; | 365 | int warn; |
366 | if ( nextAlarm(ev,when,warn) ) | 366 | if ( nextAlarm(ev,when,warn) ) |
367 | AlarmServer::addAlarm( when, | 367 | AlarmServer::addAlarm( when, |
368 | "QPE/Application/datebook", | 368 | "QPE/Application/datebook", |
369 | "alarm(QDateTime,int)", warn ); | 369 | "alarm(QDateTime,int)", warn ); |
370 | } | 370 | } |
371 | 371 | ||
372 | static void delEventAlarm( const Event &ev ) | 372 | static void delEventAlarm( const Event &ev ) |
373 | { | 373 | { |
374 | QDateTime when; | 374 | QDateTime when; |
375 | int warn; | 375 | int warn; |
376 | if ( nextAlarm(ev,when,warn) ) | 376 | if ( nextAlarm(ev,when,warn) ) |
377 | AlarmServer::deleteAlarm( when, | 377 | AlarmServer::deleteAlarm( when, |
378 | "QPE/Application/datebook", | 378 | "QPE/Application/datebook", |
379 | "alarm(QDateTime,int)", warn ); | 379 | "alarm(QDateTime,int)", warn ); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | DateBookDB::DateBookDB() | 383 | DateBookDB::DateBookDB() |
384 | { | 384 | { |
385 | init(); | 385 | init(); |
386 | } | 386 | } |
387 | 387 | ||
388 | DateBookDB::~DateBookDB() | 388 | DateBookDB::~DateBookDB() |
389 | { | 389 | { |
390 | save(); | 390 | save(); |
391 | eventList.clear(); | 391 | eventList.clear(); |
392 | repeatEvents.clear(); | 392 | repeatEvents.clear(); |
393 | |||
394 | delete d; | ||
395 | d=0; | ||
393 | } | 396 | } |
394 | 397 | ||
395 | 398 | ||
396 | //#### Why is this code duplicated in getEffectiveEvents ????? | 399 | //#### Why is this code duplicated in getEffectiveEvents ????? |
397 | //#### Addendum. Don't use this function, lets faze it out if we can. | 400 | //#### Addendum. Don't use this function, lets faze it out if we can. |
398 | QValueList<Event> DateBookDB::getEvents( const QDate &from, const QDate &to ) | 401 | QValueList<Event> DateBookDB::getEvents( const QDate &from, const QDate &to ) |
399 | { | 402 | { |
400 | QValueList<Event> tmpList; | 403 | QValueList<Event> tmpList; |
401 | tmpList = getNonRepeatingEvents( from, to ); | 404 | tmpList = getNonRepeatingEvents( from, to ); |
402 | 405 | ||
403 | // check for repeating events... | 406 | // check for repeating events... |
404 | for (QValueList<Event>::ConstIterator it = repeatEvents.begin(); | 407 | for (QValueList<Event>::ConstIterator it = repeatEvents.begin(); |
405 | it != repeatEvents.end(); ++it) { | 408 | it != repeatEvents.end(); ++it) { |
406 | QDate itDate = from; | 409 | QDate itDate = from; |
407 | QDateTime due; | 410 | QDateTime due; |
408 | 411 | ||
409 | /* create a false end date, to short circuit on hard | 412 | /* create a false end date, to short circuit on hard |
410 | MonthlyDay recurences */ | 413 | MonthlyDay recurences */ |
411 | Event dummy_event = *it; | 414 | Event dummy_event = *it; |
412 | Event::RepeatPattern r = dummy_event.repeatPattern(); | 415 | Event::RepeatPattern r = dummy_event.repeatPattern(); |
413 | if ( !r.hasEndDate || r.endDate() > to ) { | 416 | if ( !r.hasEndDate || r.endDate() > to ) { |
414 | r.setEndDate( to ); | 417 | r.setEndDate( to ); |
415 | r.hasEndDate = TRUE; | 418 | r.hasEndDate = TRUE; |
416 | } | 419 | } |
417 | dummy_event.setRepeat(TRUE, r); | 420 | dummy_event.setRepeat(TRUE, r); |
418 | 421 | ||
419 | while (nextOccurance(dummy_event, itDate, due)) { | 422 | while (nextOccurance(dummy_event, itDate, due)) { |
420 | if (due.date() > to) | 423 | if (due.date() > to) |
421 | break; | 424 | break; |
422 | Event newEvent = *it; | 425 | Event newEvent = *it; |
423 | newEvent.setStart(due); | 426 | newEvent.setStart(due); |
424 | newEvent.setEnd(due.addSecs((*it).start().secsTo((*it).end()))); | 427 | newEvent.setEnd(due.addSecs((*it).start().secsTo((*it).end()))); |
425 | 428 | ||
426 | tmpList.append(newEvent); | 429 | tmpList.append(newEvent); |
427 | itDate = due.date().addDays(1); /* the next event */ | 430 | itDate = due.date().addDays(1); /* the next event */ |
428 | } | 431 | } |
429 | } | 432 | } |
430 | qHeapSort(tmpList); | 433 | qHeapSort(tmpList); |
431 | return tmpList; | 434 | return tmpList; |
432 | } | 435 | } |
433 | 436 | ||
434 | QValueList<Event> DateBookDB::getEvents( const QDateTime &start ) | 437 | QValueList<Event> DateBookDB::getEvents( const QDateTime &start ) |
435 | { | 438 | { |
436 | QValueList<Event> day = getEvents(start.date(),start.date()); | 439 | QValueList<Event> day = getEvents(start.date(),start.date()); |
437 | 440 | ||
438 | QValueListConstIterator<Event> it; | 441 | QValueListConstIterator<Event> it; |
439 | QDateTime dtTmp; | 442 | QDateTime dtTmp; |
440 | QValueList<Event> tmpList; | 443 | QValueList<Event> tmpList; |