diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-02-12 19:27:51 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-02-12 19:48:53 +0100 |
commit | 47b822604d81a6c603ce6c9e868456c8ccc2e18d (patch) | |
tree | 73f06796cff7941b9f0e7ab2b2a9e59054da0afa /src/timeline/TimelineModel.cpp | |
parent | Hidden events: Make reusable read function (diff) | |
download | nheko-47b822604d81a6c603ce6c9e868456c8ccc2e18d.tar.xz |
Hidden events: Refactor slightly for reusability
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 112 |
1 files changed, 59 insertions, 53 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index c7aa0fa2..662bbb38 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -50,59 +50,7 @@ struct RoomEventType template<class T> qml_mtx_events::EventType operator()(const mtx::events::Event<T> &e) { - using mtx::events::EventType; - switch (e.type) { - case EventType::RoomKeyRequest: - return qml_mtx_events::EventType::KeyRequest; - case EventType::Reaction: - return qml_mtx_events::EventType::Reaction; - case EventType::RoomAliases: - return qml_mtx_events::EventType::Aliases; - case EventType::RoomAvatar: - return qml_mtx_events::EventType::Avatar; - case EventType::RoomCanonicalAlias: - return qml_mtx_events::EventType::CanonicalAlias; - case EventType::RoomCreate: - return qml_mtx_events::EventType::RoomCreate; - case EventType::RoomEncrypted: - return qml_mtx_events::EventType::Encrypted; - case EventType::RoomEncryption: - return qml_mtx_events::EventType::Encryption; - case EventType::RoomGuestAccess: - return qml_mtx_events::EventType::RoomGuestAccess; - case EventType::RoomHistoryVisibility: - return qml_mtx_events::EventType::RoomHistoryVisibility; - case EventType::RoomJoinRules: - return qml_mtx_events::EventType::RoomJoinRules; - case EventType::RoomMember: - return qml_mtx_events::EventType::Member; - case EventType::RoomMessage: - return qml_mtx_events::EventType::UnknownMessage; - case EventType::RoomName: - return qml_mtx_events::EventType::Name; - case EventType::RoomPowerLevels: - return qml_mtx_events::EventType::PowerLevels; - case EventType::RoomTopic: - return qml_mtx_events::EventType::Topic; - case EventType::RoomTombstone: - return qml_mtx_events::EventType::Tombstone; - case EventType::RoomRedaction: - return qml_mtx_events::EventType::Redaction; - case EventType::RoomPinnedEvents: - return qml_mtx_events::EventType::PinnedEvents; - case EventType::Sticker: - return qml_mtx_events::EventType::Sticker; - case EventType::Tag: - return qml_mtx_events::EventType::Tag; - case EventType::SpaceParent: - return qml_mtx_events::EventType::SpaceParent; - case EventType::SpaceChild: - return qml_mtx_events::EventType::SpaceChild; - case EventType::Unsupported: - return qml_mtx_events::EventType::Unsupported; - default: - return qml_mtx_events::EventType::UnknownMessage; - } + return qml_mtx_events::toRoomEventType(e.type); } qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::msg::Audio> &) { @@ -199,6 +147,64 @@ struct RoomEventType } qml_mtx_events::EventType +qml_mtx_events::toRoomEventType(mtx::events::EventType e) +{ + using mtx::events::EventType; + switch (e) { + case EventType::RoomKeyRequest: + return qml_mtx_events::EventType::KeyRequest; + case EventType::Reaction: + return qml_mtx_events::EventType::Reaction; + case EventType::RoomAliases: + return qml_mtx_events::EventType::Aliases; + case EventType::RoomAvatar: + return qml_mtx_events::EventType::Avatar; + case EventType::RoomCanonicalAlias: + return qml_mtx_events::EventType::CanonicalAlias; + case EventType::RoomCreate: + return qml_mtx_events::EventType::RoomCreate; + case EventType::RoomEncrypted: + return qml_mtx_events::EventType::Encrypted; + case EventType::RoomEncryption: + return qml_mtx_events::EventType::Encryption; + case EventType::RoomGuestAccess: + return qml_mtx_events::EventType::RoomGuestAccess; + case EventType::RoomHistoryVisibility: + return qml_mtx_events::EventType::RoomHistoryVisibility; + case EventType::RoomJoinRules: + return qml_mtx_events::EventType::RoomJoinRules; + case EventType::RoomMember: + return qml_mtx_events::EventType::Member; + case EventType::RoomMessage: + return qml_mtx_events::EventType::UnknownMessage; + case EventType::RoomName: + return qml_mtx_events::EventType::Name; + case EventType::RoomPowerLevels: + return qml_mtx_events::EventType::PowerLevels; + case EventType::RoomTopic: + return qml_mtx_events::EventType::Topic; + case EventType::RoomTombstone: + return qml_mtx_events::EventType::Tombstone; + case EventType::RoomRedaction: + return qml_mtx_events::EventType::Redaction; + case EventType::RoomPinnedEvents: + return qml_mtx_events::EventType::PinnedEvents; + case EventType::Sticker: + return qml_mtx_events::EventType::Sticker; + case EventType::Tag: + return qml_mtx_events::EventType::Tag; + case EventType::SpaceParent: + return qml_mtx_events::EventType::SpaceParent; + case EventType::SpaceChild: + return qml_mtx_events::EventType::SpaceChild; + case EventType::Unsupported: + return qml_mtx_events::EventType::Unsupported; + default: + return qml_mtx_events::EventType::UnknownMessage; + } +} + +qml_mtx_events::EventType toRoomEventType(const mtx::events::collections::TimelineEvents &event) { return std::visit(RoomEventType{}, event); |