aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommemberevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-08-06 12:01:22 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-08-06 12:01:22 +0900
commitc0e75a52504a3d31bcca0d4c39745d4d6c1fe917 (patch)
treea739984cbedefebdeda610be7a97c127fe10b5e1 /lib/events/roommemberevent.cpp
parent8bd8aaf0858bb0a0ebcac8c3d29cfbb20279164d (diff)
downloadlibquotient-c0e75a52504a3d31bcca0d4c39745d4d6c1fe917.tar.gz
libquotient-c0e75a52504a3d31bcca0d4c39745d4d6c1fe917.zip
RoomMemberEvent: a set of is*() facility methods
Diffstat (limited to 'lib/events/roommemberevent.cpp')
-rw-r--r--lib/events/roommemberevent.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp
index 79e4af2d..eaa3302c 100644
--- a/lib/events/roommemberevent.cpp
+++ b/lib/events/roommemberevent.cpp
@@ -48,6 +48,7 @@ namespace QMatrixClient
return MembershipType::Undefined;
}
};
+
}
MemberEventContent::MemberEventContent(const QJsonObject& json)
@@ -68,3 +69,34 @@ void MemberEventContent::fillJson(QJsonObject* o) const
if (avatarUrl.isValid())
o->insert(QStringLiteral("avatar_url"), avatarUrl.toString());
}
+
+bool RoomMemberEvent::isInvite() const
+{
+ return membership() == MembershipType::Invite &&
+ (!prevContent() || prevContent()->membership != membership());
+}
+
+bool RoomMemberEvent::isJoin() const
+{
+ return membership() == MembershipType::Join &&
+ (!prevContent() || prevContent()->membership != membership());
+}
+
+bool RoomMemberEvent::isLeave() const
+{
+ return membership() == MembershipType::Leave &&
+ prevContent() && prevContent()->membership != membership() &&
+ prevContent()->membership != MembershipType::Ban;
+}
+
+bool RoomMemberEvent::isRename() const
+{
+ auto prevName = prevContent() ? prevContent()->displayName : QString();
+ return displayName() != prevName;
+}
+
+bool RoomMemberEvent::isAvatarUpdate() const
+{
+ auto prevAvatarUrl = prevContent() ? prevContent()->avatarUrl : QUrl();
+ return avatarUrl() != prevAvatarUrl;
+}