aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-30 14:06:12 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-30 14:06:12 +0900
commitf5651c74ddddd8c66b3b42b471fbe2ff278c0d9a (patch)
treea605cc20873ca915b97d5916d285aaffcedc431c /lib
parent2c7f3f2a15afcdd7d5200757daa6629239593e02 (diff)
downloadlibquotient-f5651c74ddddd8c66b3b42b471fbe2ff278c0d9a.tar.gz
libquotient-f5651c74ddddd8c66b3b42b471fbe2ff278c0d9a.zip
Room: Unify tags both when getting and setting
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index f41fe12c..ee2e2b8e 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -752,6 +752,18 @@ void Room::setTags(TagsMap newTags)
void Room::Private::setTags(TagsMap newTags)
{
emit q->tagsAboutToChange();
+ const auto keys = newTags.keys();
+ for (const auto& k: keys)
+ {
+ const auto& checkRes = validatedTag(k);
+ if (checkRes.first)
+ {
+ if (newTags.contains(checkRes.second))
+ newTags.remove(k);
+ else
+ newTags.insert(checkRes.second, newTags.take(k));
+ }
+ }
tags = move(newTags);
qCDebug(MAIN) << "Room" << q->objectName() << "is tagged with"
<< q->tagNames().join(", ");