Commit 676b8f98 authored by Volker Krause's avatar Volker Krause
Browse files

Exclude ongoing location changes from weather forecast intervals

parent f9a5e75b
Pipeline #169300 passed with stage
in 1 minute and 29 seconds
......@@ -513,6 +513,12 @@ void TimelineModel::updateWeatherElements()
qDebug() << "recomputing weather elements";
GeoCoordinates geo;
auto date = now();
// round to next full hour
date.setTime(QTime(date.time().hour(), 0));
date = date.addSecs(60 * 60);
const auto maxForecastTime = m_weatherMgr->maximumForecastTime(date.date());
// look through the past, clean up weather elements there and figure out where we are
auto it = m_elements.begin();
for (; it != m_elements.end() && (*it).dt < now();) {
......@@ -531,17 +537,17 @@ void TimelineModel::updateWeatherElements()
const auto newGeo = (*it).destinationCoordinates();
if ((*it).isLocationChange() || newGeo.isValid()) {
geo = newGeo;
// if we are in an ongoing location change, start afterwards
const auto endDt = (*it).endDateTime();
if (endDt.isValid() && date < endDt) {
date = endDt;
}
}
++it;
}
auto date = now();
// round to next full hour
date.setTime(QTime(date.time().hour(), 0));
date = date.addSecs(60 * 60);
const auto maxForecastTime = m_weatherMgr->maximumForecastTime(date.date());
while(it != m_elements.end() && date < maxForecastTime) {
if ((*it).dt < date || (*it).elementType == TimelineElement::TodayMarker) {
......
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