aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-20 14:50:33 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-20 14:50:33 +0900
commit72ff8cf1e77e859de08e343df964f496dc2f9dd8 (patch)
treec1f825962758141d0183543a2e01560951e37782
parent959b2d023d37713cefaee049b09e09507107e4b0 (diff)
downloadlibquotient-72ff8cf1e77e859de08e343df964f496dc2f9dd8.tar.gz
libquotient-72ff8cf1e77e859de08e343df964f496dc2f9dd8.zip
RoomMessageEvent::hasTextContent()
Similar to hasFileContent(), allows to ascertain that an event has TextContent without checking against all possible msgtypes.
-rw-r--r--events/roommessageevent.cpp7
-rw-r--r--events/roommessageevent.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp
index 3c5d10ad..8c088f21 100644
--- a/events/roommessageevent.cpp
+++ b/events/roommessageevent.cpp
@@ -116,6 +116,13 @@ QMimeType RoomMessageEvent::mimeType() const
QMimeDatabase().mimeTypeForName("text/plain");
}
+bool RoomMessageEvent::hasTextContent() const
+{
+ return content() &&
+ (msgtype() == MsgType::Text || msgtype() == MsgType::Emote ||
+ msgtype() == MsgType::Notice); // FIXME: Unbind from specific msgtypes
+}
+
bool RoomMessageEvent::hasFileContent() const
{
return content() && content()->fileInfo();
diff --git a/events/roommessageevent.h b/events/roommessageevent.h
index 867d8880..2a5eeb7e 100644
--- a/events/roommessageevent.h
+++ b/events/roommessageevent.h
@@ -59,6 +59,7 @@ namespace QMatrixClient
EventContent::TypedBase* content() const
{ return _content.data(); }
QMimeType mimeType() const;
+ bool hasTextContent() const;
bool hasFileContent() const;
QJsonObject toJson() const;