Improve sections

Now they are displayed for each day (if there was at least one message
on that day) instead of every few hours
This commit is contained in:
Carl Schwan
2020-11-22 14:51:25 +00:00
parent beafc572c4
commit a7e06a6529
2 changed files with 5 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
#include <user.h>
#include <QDebug>
#include <QTimeZone>
#include <QQmlEngine> // for qmlRegisterType()
#include <KLocalizedString>
@@ -452,7 +453,9 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
for (auto r = row + 1; r < rowCount(); ++r) {
auto i = index(r);
if (data(i, SpecialMarksRole) != EventStatus::Hidden) {
return data(i, TimeRole).toDateTime().msecsTo(data(idx, TimeRole).toDateTime()) > 600000;
const auto day = data(idx, TimeRole).toDateTime().toLocalTime().date().dayOfYear();
const auto previousEventDay = data(i, TimeRole).toDateTime().toLocalTime().date().dayOfYear();
return day != previousEventDay;
}
}