aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-16 17:25:04 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-09-16 17:35:27 +0900
commit52931841d816e2fd128579ef7e51eec1cbd0bb09 (patch)
treea181ee74c9fb47e138d369f341a37d6b7f73a24c /lib
parent343341e1422251a863149cad515b955aae395569 (diff)
downloadlibquotient-52931841d816e2fd128579ef7e51eec1cbd0bb09.tar.gz
libquotient-52931841d816e2fd128579ef7e51eec1cbd0bb09.zip
Introduce Room::displaynameAboutToChange()
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp15
-rw-r--r--lib/room.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 869a81c8..c34c0e44 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -752,7 +752,7 @@ void Room::Private::setTags(TagsMap newTags)
{
emit q->tagsAboutToChange();
tags = move(newTags);
- qCDebug(MAIN) << "Room" << id << "is tagged with:"
+ qCDebug(MAIN) << "Room" << q->objectName() << "is tagged with"
<< q->tagNames().join(", ");
emit q->tagsChanged();
}
@@ -1948,10 +1948,15 @@ QString Room::Private::calculateDisplayname() const
void Room::Private::updateDisplayname()
{
- const QString oldName = displayname;
- displayname = calculateDisplayname();
- if (oldName != displayname)
- emit q->displaynameChanged(q, oldName);
+ auto swappedName = calculateDisplayname();
+ if (swappedName != displayname)
+ {
+ emit q->displaynameAboutToChange(q);
+ swap(displayname, swappedName);
+ qDebug(MAIN) << q->objectName() << "has changed display name from"
+ << swappedName << "to" << displayname;
+ emit q->displaynameChanged(q, swappedName);
+ }
}
void appendStateEvent(QJsonArray& events, const QString& type,
diff --git a/lib/room.h b/lib/room.h
index 70867183..c0ff60af 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -363,7 +363,7 @@ namespace QMatrixClient
* Not triggered when displayname changes.
*/
void namesChanged(Room* room);
- /// The room displayname changed
+ void displaynameAboutToChange(Room* room);
void displaynameChanged(Room* room, QString oldName);
void topicChanged();
void avatarChanged();