diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-06 12:01:22 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-06 12:01:22 +0900 |
commit | c0e75a52504a3d31bcca0d4c39745d4d6c1fe917 (patch) | |
tree | a739984cbedefebdeda610be7a97c127fe10b5e1 /lib/events/roommemberevent.cpp | |
parent | 8bd8aaf0858bb0a0ebcac8c3d29cfbb20279164d (diff) | |
download | libquotient-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.cpp | 32 |
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; +} |