Commit c8ad4c0a authored by Volker Krause's avatar Volker Krause
Browse files

Use the new plural form for finding calendar events

This allows us to find all elements of a multi-leg trip if we received
a minimal cancellation elements for all of them.
parent f041c62c
...@@ -100,17 +100,20 @@ QVector<ItineraryMemento::TripData> ItineraryMemento::data() ...@@ -100,17 +100,20 @@ QVector<ItineraryMemento::TripData> ItineraryMemento::data()
resolvedEvents.reserve(postProcResult.size()); resolvedEvents.reserve(postProcResult.size());
const auto calendar = CalendarSupport::calendarSingleton(!qEnvironmentVariableIsSet("BPF_ITINERARY_TESTMODE")); const auto calendar = CalendarSupport::calendarSingleton(!qEnvironmentVariableIsSet("BPF_ITINERARY_TESTMODE"));
for (const auto &r : qAsConst(postProcResult)) { for (const auto &r : qAsConst(postProcResult)) {
auto e = std::make_pair(r, CalendarHandler::findEvent(calendar, r)); const auto events = CalendarHandler::findEvents(calendar, r);
if (e.second) { if (events.empty()) {
const auto existingRes = CalendarHandler::reservationsForEvent(e.second); resolvedEvents.push_back(std::make_pair(r, KCalendarCore::Event::Ptr()));
continue;
}
for (const auto &event : events) {
const auto existingRes = CalendarHandler::reservationsForEvent(event);
for (const auto &ev : existingRes) { for (const auto &ev : existingRes) {
if (MergeUtil::isSame(ev, e.first)) { if (MergeUtil::isSame(ev, r)) {
e.first = MergeUtil::merge(ev, e.first); resolvedEvents.push_back(std::make_pair(MergeUtil::merge(ev, r), event));
break;
} }
} }
} }
resolvedEvents.push_back(e);
} }
// discard elemnents we couldn't complete from the calendar // discard elemnents we couldn't complete from the calendar
......
Markdown is supported
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