From e997f214562acf30ae8d4ea7132dde6e583ac6fe Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 23 Aug 2019 08:09:28 +0900 Subject: RoomMessageEvent::content(): constify event content --- lib/events/eventcontent.h | 2 ++ lib/events/roommessageevent.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/events') diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h index c26cb931..e7656de5 100644 --- a/lib/events/eventcontent.h +++ b/lib/events/eventcontent.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace Quotient { namespace EventContent { @@ -276,3 +277,4 @@ namespace EventContent { using FileContent = UrlWithThumbnailContent; } // namespace EventContent } // namespace Quotient +Q_DECLARE_METATYPE(const Quotient::EventContent::TypedBase*) diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index b393382a..e95aabfc 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -34,7 +34,7 @@ class RoomMessageEvent : public RoomEvent { Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT) Q_PROPERTY(QString plainBody READ plainBody CONSTANT) Q_PROPERTY(QMimeType mimeType READ mimeType STORED false CONSTANT) - Q_PROPERTY(EventContent::TypedBase* content READ content CONSTANT) + Q_PROPERTY(const EventContent::TypedBase* content READ content CONSTANT) public: DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent) @@ -62,13 +62,13 @@ public: MsgType msgtype() const; QString rawMsgtype() const; QString plainBody() const; - EventContent::TypedBase* content() const { return _content.data(); } + const EventContent::TypedBase* content() const { return _content.data(); } template - void editContent(VisitorT visitor) + void editContent(VisitorT&& visitor) { visitor(*_content); editJson()[ContentKeyL] = assembleContentJson(plainBody(), rawMsgtype(), - content()); + _content.data()); } QMimeType mimeType() const; bool hasTextContent() const; -- cgit v1.2.3