From 24f370d6c0a779373d1484206bb8ff617b1e24f2 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 2 Jun 2023 02:58:36 +0200 Subject: Use multidata in timeline model --- src/timeline/TimelineModel.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 0e99e7e1..f3b3ce81 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -875,7 +875,6 @@ QVariant TimelineModel::data(const QModelIndex &index, int role) const { using namespace mtx::accessors; - namespace acc = mtx::accessors; if (index.row() < 0 && index.row() >= rowCount()) return {}; @@ -891,6 +890,28 @@ TimelineModel::data(const QModelIndex &index, int role) const return data(*event, role); } +void +TimelineModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const +{ + if (index.row() < 0 && index.row() >= rowCount()) + return; + + // HACK(Nico): fetchMore likes to break with dynamically sized delegates and reuseItems + if (index.row() + 1 == rowCount() && !m_paginationInProgress) + const_cast(this)->fetchMore(index); + + auto event = events.get(rowCount() - index.row() - 1); + + if (!event) + return; + + for (QModelRoleData &roleData : roleDataSpan) { + int role = roleData.role(); + + roleData.setData(data(*event, role)); + } +} + QVariant TimelineModel::dataById(const QString &id, int role, const QString &relatedTo) { -- cgit 1.5.1