Commit c6a24b2b authored by Volker Krause's avatar Volker Krause
Browse files

Add section headers to the timeline model

parent d7f1e821
......@@ -48,5 +48,18 @@ Kirigami.ScrollablePage {
passId: model.passId
}
}
section.property: "sectionHeader"
section.delegate: Rectangle {
color: Kirigami.Theme.backgroundColor
implicitHeight: headerItem.implicitHeight
implicitWidth: ListView.view.width
Kirigami.BasicListItem {
id: headerItem
label: section
icon: "view-calendar-day"
}
}
section.criteria: ViewSection.FullString
section.labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels
}
}
......@@ -21,6 +21,7 @@
#include <KPkPass/File>
#include <QDebug>
#include <QLocale>
TimelineModel::TimelineModel(QObject *parent)
: QAbstractListModel(parent)
......@@ -58,6 +59,8 @@ QVariant TimelineModel::data(const QModelIndex& index, int role) const
return QVariant::fromValue(m_mgr->pass(m_passes.at(index.row())));
case PassIdRole:
return m_passes.at(index.row());
case SectionHeader:
return QLocale().toString(m_mgr->pass(m_passes.at(index.row()))->relevantDate().date(), QLocale::ShortFormat);
}
return {};
}
......@@ -67,6 +70,7 @@ QHash<int, QByteArray> TimelineModel::roleNames() const
auto names = QAbstractListModel::roleNames();
names.insert(PassRole, "pass");
names.insert(PassIdRole, "passId");
names.insert(SectionHeader, "sectionHeader");
return names;
}
......
......@@ -28,7 +28,8 @@ class TimelineModel : public QAbstractListModel
public:
enum Role {
PassRole = Qt::UserRole + 1,
PassIdRole
PassIdRole,
SectionHeader
};
explicit TimelineModel(QObject *parent = nullptr);
~TimelineModel();
......
Markdown is supported
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