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

@@ -10,8 +10,7 @@ import org.kde.kirigami 2.13 as Kirigami
Kirigami.Heading {
level: 4
text: section + " • " + Qt.formatTime(time)
font.capitalization: Font.AllUppercase
text: section
verticalAlignment: Text.AlignVCenter
topPadding: Kirigami.Units.largeSpacing * 2
bottomPadding: Kirigami.Units.smallSpacing

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;
}
}