Changeset View
Changeset View
Standalone View
Standalone View
src/alarmcalendar.cpp
Show First 20 Lines • Show All 461 Lines • ▼ Show 20 Line(s) | |||||
462 | * the AlarmCalendar is closed. | 462 | * the AlarmCalendar is closed. | ||
463 | */ | 463 | */ | ||
464 | void AlarmCalendar::removeKAEvents(Collection::Id key, bool closing, CalEvent::Types types) | 464 | void AlarmCalendar::removeKAEvents(Collection::Id key, bool closing, CalEvent::Types types) | ||
465 | { | 465 | { | ||
466 | bool removed = false; | 466 | bool removed = false; | ||
467 | ResourceMap::Iterator rit = mResourceMap.find(key); | 467 | ResourceMap::Iterator rit = mResourceMap.find(key); | ||
468 | if (rit != mResourceMap.end()) | 468 | if (rit != mResourceMap.end()) | ||
469 | { | 469 | { | ||
470 | bool empty = true; | 470 | KAEvent::List retained; | ||
471 | KAEvent::List& events = rit.value(); | 471 | KAEvent::List& events = rit.value(); | ||
472 | for (int i = 0, end = events.count(); i < end; ++i) | 472 | for (int i = 0, end = events.count(); i < end; ++i) | ||
473 | { | 473 | { | ||
474 | KAEvent* event = events[i]; | 474 | KAEvent* event = events[i]; | ||
475 | bool remove = (event->collectionId() != key); | 475 | bool remove = (event->collectionId() != key); | ||
476 | if (remove) | 476 | if (remove) | ||
477 | { | 477 | { | ||
478 | if (key != DISPLAY_COL_ID) | 478 | if (key != DISPLAY_COL_ID) | ||
479 | qCCritical(KALARM_LOG) << "AlarmCalendar::removeKAEvents: Event" << event->id() << ", collection" << event->collectionId() << "Indexed under collection" << key; | 479 | qCCritical(KALARM_LOG) << "AlarmCalendar::removeKAEvents: Event" << event->id() << ", collection" << event->collectionId() << "Indexed under collection" << key; | ||
480 | } | 480 | } | ||
481 | else | 481 | else | ||
482 | remove = event->category() & types; | 482 | remove = event->category() & types; | ||
483 | if (remove) | 483 | if (remove) | ||
484 | { | 484 | { | ||
485 | mEventMap.remove(EventId(key, event->id())); | 485 | mEventMap.remove(EventId(key, event->id())); | ||
486 | delete event; | 486 | delete event; | ||
487 | removed = true; | 487 | removed = true; | ||
488 | } | 488 | } | ||
489 | else | 489 | else | ||
490 | empty = false; | 490 | retained.push_back(event); | ||
491 | } | 491 | } | ||
492 | if (empty) | 492 | if (retained.empty()) | ||
493 | mResourceMap.erase(rit); | 493 | mResourceMap.erase(rit); | ||
494 | else | ||||
495 | events.swap(retained); | ||||
494 | } | 496 | } | ||
495 | if (removed) | 497 | if (removed) | ||
496 | { | 498 | { | ||
497 | mEarliestAlarm.remove(key); | 499 | mEarliestAlarm.remove(key); | ||
498 | // Emit signal only if we're not in the process of closing the calendar | 500 | // Emit signal only if we're not in the process of closing the calendar | ||
499 | if (!closing && mOpen) | 501 | if (!closing && mOpen) | ||
500 | { | 502 | { | ||
501 | Q_EMIT earliestAlarmChanged(); | 503 | Q_EMIT earliestAlarmChanged(); | ||
▲ Show 20 Lines • Show All 1105 Lines • Show Last 20 Lines |