author | zecke <zecke> | 2004-09-12 20:43:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-12 20:43:22 (UTC) |
commit | 0f705db7c338e9642294823333e5f4410aa0573f (patch) (unidiff) | |
tree | 98e35fc5d53b0730ebeb49baaff391b5cd28386f /library | |
parent | 40440f2652c582c108a5236d8b5398dbd6b68b18 (diff) | |
download | opie-0f705db7c338e9642294823333e5f4410aa0573f.zip opie-0f705db7c338e9642294823333e5f4410aa0573f.tar.gz opie-0f705db7c338e9642294823333e5f4410aa0573f.tar.bz2 |
Delete the d pointer
-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 | |||
@@ -329,128 +329,131 @@ bool nextOccurance(const Event &e, const QDate &from, QDateTime &next) | |||
329 | if ((next.date() > e.repeatPattern().endDate()) && e.repeatPattern().hasEndDate) | 329 | if ((next.date() > e.repeatPattern().endDate()) && e.repeatPattern().hasEndDate) |
330 | return FALSE; | 330 | return FALSE; |
331 | return TRUE; | 331 | return TRUE; |
332 | default: | 332 | default: |
333 | return FALSE; | 333 | return FALSE; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | static bool nextAlarm( const Event &ev, QDateTime& when, int& warn) | 337 | static bool nextAlarm( const Event &ev, QDateTime& when, int& warn) |
338 | { | 338 | { |
339 | QDateTime now = QDateTime::currentDateTime(); | 339 | QDateTime now = QDateTime::currentDateTime(); |
340 | if ( ev.hasRepeat() ) { | 340 | if ( ev.hasRepeat() ) { |
341 | QDateTime ralarm; | 341 | QDateTime ralarm; |
342 | if (nextOccurance(ev, now.date(), ralarm)) { | 342 | if (nextOccurance(ev, now.date(), ralarm)) { |
343 | ralarm = ralarm.addSecs(-ev.alarmTime()*60); | 343 | ralarm = ralarm.addSecs(-ev.alarmTime()*60); |
344 | if ( ralarm > now ) { | 344 | if ( ralarm > now ) { |
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; |
441 | for (it = day.begin(); it != day.end(); ++it ) { | 444 | for (it = day.begin(); it != day.end(); ++it ) { |
442 | dtTmp = (*it).start(TRUE); | 445 | dtTmp = (*it).start(TRUE); |
443 | if ( dtTmp == start ) | 446 | if ( dtTmp == start ) |
444 | tmpList.append( *it ); | 447 | tmpList.append( *it ); |
445 | } | 448 | } |
446 | return tmpList; | 449 | return tmpList; |
447 | } | 450 | } |
448 | 451 | ||
449 | //#### Why is this code duplicated in getEvents ????? | 452 | //#### Why is this code duplicated in getEvents ????? |
450 | 453 | ||
451 | QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from, | 454 | QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDate &from, |
452 | const QDate &to ) | 455 | const QDate &to ) |
453 | { | 456 | { |
454 | QValueList<EffectiveEvent> tmpList; | 457 | QValueList<EffectiveEvent> tmpList; |
455 | QValueListIterator<Event> it; | 458 | QValueListIterator<Event> it; |
456 | 459 | ||