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

Expect the today marker anywhere when checking for empty days

This prepares for the "today" action becoming rather a "now" action.
parent 0b1fd98b
......@@ -214,7 +214,7 @@ QVariant TimelineModel::data(const QModelIndex& index, int role) const
return elem.elementType;
case TodayEmptyRole:
if (elem.elementType == TimelineElement::TodayMarker) {
return index.row() == (int)(m_elements.size() - 1) || m_elements.at(index.row() + 1).dt.date() > today();
return isDateEmpty(m_elements.at(index.row()).dt.date());
}
return {};
case IsTodayRole:
......@@ -894,3 +894,19 @@ QVariant TimelineModel::locationAtTime(const QDateTime& dt) const
}
return {};
}
bool TimelineModel::isDateEmpty(const QDate &date) const
{
auto it = std::lower_bound(m_elements.begin(), m_elements.end(), date, [](const auto &lhs, auto rhs) {
return lhs.dt.date() < rhs;
});
for (; it != m_elements.end(); ++it) {
if ((*it).dt.date() == date && (*it).elementType != TimelineElement::TodayMarker) {
return false;
}
if ((*it).dt.date() != date) {
break;
}
}
return true;
}
......@@ -97,6 +97,7 @@ private:
void updateTransfersForBatch(const QString &batchId);
void scheduleCurrentBatchTimer();
bool isDateEmpty(const QDate &date) const;
ReservationManager *m_resMgr = nullptr;
WeatherForecastManager *m_weatherMgr = nullptr;
......
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