Commit 0f069baa authored by Volker Krause's avatar Volker Krause
Browse files

Determine active alarms without copying incidences

This apparently was done to filter blocked alarms early, but we can just
as well do that later. This has the welcome side-effect that it doesn't
break Alarm::parentUid() and we can therefore also get rid of the ETM
specific custom property hack here.
parent 7632a982
Pipeline #108392 passed with stage
in 58 seconds
......@@ -3,7 +3,7 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.19.40")
set(PIM_VERSION "5.19.41")
project(Akonadi-Calendar VERSION ${PIM_VERSION})
# ECM setup
......
......@@ -522,26 +522,9 @@ KCalendarCore::Alarm::List ETMCalendar::alarms(const QDateTime &from, const QDat
KCalendarCore::Incidence::Ptr incidence;
if (item.isValid() && item.hasPayload<KCalendarCore::Incidence::Ptr>()) {
incidence = KCalendarCore::Incidence::Ptr(item.payload<KCalendarCore::Incidence::Ptr>()->clone());
} else {
continue;
incidence = item.payload<KCalendarCore::Incidence::Ptr>();
}
if (!incidence) {
continue;
}
if (blockedAttr) {
// Remove all blocked types of alarms
const auto alarmsLst = incidence->alarms();
for (const KCalendarCore::Alarm::Ptr &alarm : alarmsLst) {
if (blockedAttr->isAlarmTypeBlocked(alarm->type())) {
incidence->removeAlarm(alarm);
}
}
}
if (incidence->alarms().isEmpty()) {
if (!incidence || incidence->alarms().isEmpty()) {
continue;
}
......@@ -552,13 +535,15 @@ KCalendarCore::Alarm::List ETMCalendar::alarms(const QDateTime &from, const QDat
appendAlarms(tmpList, incidence, from, to);
}
// We need to tag them with the incidence uid in case
// the caller will need it, because when we get out of
// this scope the incidence will be destroyed.
QVectorIterator<Alarm::Ptr> a(tmpList);
while (a.hasNext()) {
a.next()->setCustomProperty("ETMCalendar", "parentUid", incidence->uid());
if (blockedAttr) {
tmpList.erase(std::remove_if(tmpList.begin(),
tmpList.end(),
[blockedAttr](const auto &alarm) {
return blockedAttr->isAlarmTypeBlocked(alarm->type());
}),
tmpList.end());
}
alarmList += tmpList;
}
return alarmList;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment