diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-12-26 19:31:11 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-01-05 21:01:30 +0900 |
commit | 4ec3dd92d2cb5af4cf4893770e29db51d23e0e67 (patch) | |
tree | f61bf9d095a420d953ee6c43e4a8ecdb1a2a5039 /lib/events/roommessageevent.h | |
parent | 3ecf762f497a4d4b6ea7583689c0b9b284300201 (diff) | |
download | libquotient-4ec3dd92d2cb5af4cf4893770e29db51d23e0e67.tar.gz libquotient-4ec3dd92d2cb5af4cf4893770e29db51d23e0e67.zip |
Make content in events editable
Diffstat (limited to 'lib/events/roommessageevent.h')
-rw-r--r-- | lib/events/roommessageevent.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h index 4c29a93e..a4ba6e65 100644 --- a/lib/events/roommessageevent.h +++ b/lib/events/roommessageevent.h @@ -56,6 +56,13 @@ namespace QMatrixClient QString plainBody() const; EventContent::TypedBase* content() const { return _content.data(); } + template <typename VisitorT> + void editContent(VisitorT visitor) + { + visitor(*_content); + editJson()[ContentKeyL] = + assembleContentJson(plainBody(), rawMsgtype(), content()); + } QMimeType mimeType() const; bool hasTextContent() const; bool hasFileContent() const; @@ -64,6 +71,9 @@ namespace QMatrixClient private: QScopedPointer<EventContent::TypedBase> _content; + static QJsonObject assembleContentJson(const QString& plainBody, + const QString& jsonMsgType, EventContent::TypedBase* content); + REGISTER_ENUM(MsgType) }; REGISTER_EVENT_TYPE(RoomMessageEvent) |