[calendar] Sort the events by their type too
The QML sectioning code does not actually sort the model, this needs to be done beforehand. This should now sort the events by their type and their start datetime
This commit is contained in:
parent
ee9e5907cf
commit
e571628b18
@ -176,18 +176,18 @@ QList<QObject*> DaysModel::eventsForDate(const QDate &date)
|
||||
qDeleteAll(m_qmlData);
|
||||
m_qmlData.clear();
|
||||
|
||||
const QList<CalendarEvents::EventData> events = m_eventsData.values(date);
|
||||
QList<CalendarEvents::EventData> events = m_eventsData.values(date);
|
||||
m_qmlData.reserve(events.size());
|
||||
|
||||
// sort events by their time and type
|
||||
std::sort(events.begin(), events.end(), [](const CalendarEvents::EventData &a, const CalendarEvents::EventData &b) {
|
||||
return b.type() > a.type() || b.startDateTime() > a.startDateTime();
|
||||
});
|
||||
|
||||
Q_FOREACH (const CalendarEvents::EventData &event, events) {
|
||||
m_qmlData << new EventDataDecorator(event, this);
|
||||
}
|
||||
|
||||
// sort events by their time
|
||||
std::sort(m_qmlData.begin(), m_qmlData.end(), [](QObject *a, QObject *b) {
|
||||
return qobject_cast<EventDataDecorator*>(b)->startDateTime() > qobject_cast<EventDataDecorator*>(a)->startDateTime();
|
||||
});
|
||||
|
||||
m_agendaNeedsUpdate = false;
|
||||
return m_qmlData;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user