From e9267ffc7617cfbeb26c62cde3c28f33a898161c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 23 Jan 2020 20:59:17 +0100 Subject: [PATCH] Show event type string in placeholder --- resources/qml/delegates/Placeholder.qml | 2 +- src/timeline/TimelineModel.cpp | 11 +++++++++++ src/timeline/TimelineModel.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/qml/delegates/Placeholder.qml b/resources/qml/delegates/Placeholder.qml index 36d7b2bc..26de2067 100644 --- a/resources/qml/delegates/Placeholder.qml +++ b/resources/qml/delegates/Placeholder.qml @@ -1,7 +1,7 @@ import ".." MatrixText { - text: qsTr("unimplemented event: ") + model.data.type + text: qsTr("unimplemented event: ") + model.data.typeString width: parent ? parent.width : undefined color: inactiveColors.text } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 774e30da..f66099a0 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -119,6 +119,13 @@ toRoomEventType(const mtx::events::collections::TimelineEvents &event) return std::visit(RoomEventType{}, event); } +QString +toRoomEventTypeString(const mtx::events::collections::TimelineEvents &event) +{ + return std::visit([](const auto &e) { return QString::fromStdString(to_string(e.type)); }, + event); +} + TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObject *parent) : QAbstractListModel(parent) , room_id_(room_id) @@ -206,6 +213,7 @@ TimelineModel::roleNames() const return { {Section, "section"}, {Type, "type"}, + {TypeString, "typeString"}, {Body, "body"}, {FormattedBody, "formattedBody"}, {UserId, "userId"}, @@ -265,6 +273,8 @@ TimelineModel::data(const QString &id, int role) const return QVariant(origin_server_ts(event)); case Type: return QVariant(toRoomEventType(event)); + case TypeString: + return QVariant(toRoomEventTypeString(event)); case Body: return QVariant(utils::replaceEmoji(QString::fromStdString(body(event)))); case FormattedBody: { @@ -327,6 +337,7 @@ TimelineModel::data(const QString &id, int role) const // m.insert(names[Section], data(id, static_cast(Section))); m.insert(names[Type], data(id, static_cast(Type))); + m.insert(names[TypeString], data(id, static_cast(TypeString))); m.insert(names[Body], data(id, static_cast(Body))); m.insert(names[FormattedBody], data(id, static_cast(FormattedBody))); m.insert(names[UserId], data(id, static_cast(UserId))); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 52ab28cf..44cf79f4 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -130,6 +130,7 @@ public: { Section, Type, + TypeString, Body, FormattedBody, UserId,