aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--room.cpp4
-rw-r--r--room.h3
-rw-r--r--user.cpp7
-rw-r--r--user.h2
4 files changed, 10 insertions, 6 deletions
diff --git a/room.cpp b/room.cpp
index 1c9063c9..d79363a3 100644
--- a/room.cpp
+++ b/room.cpp
@@ -213,6 +213,7 @@ RoomEventPtr TimelineItem::replaceEvent(RoomEventPtr&& other)
Room::Room(Connection* connection, QString id, JoinState initialJoinState)
: QObject(connection), d(new Private(connection, id, initialJoinState))
{
+ setObjectName(id);
// See "Accessing the Public Class" section in
// https://marcmutz.wordpress.com/translated-articles/pimp-my-pimpl-%E2%80%94-reloaded/
d->q = this;
@@ -757,7 +758,7 @@ void Room::Private::removeMember(User* u)
}
}
-QString Room::roomMembername(User *u) const
+QString Room::roomMembername(const User* u) const
{
// See the CS spec, section 11.2.2.3
@@ -1239,6 +1240,7 @@ void Room::processStateEvents(const RoomEvents& events)
case EventType::RoomCanonicalAlias: {
auto aliasEvent = static_cast<RoomCanonicalAliasEvent*>(event);
d->canonicalAlias = aliasEvent->alias();
+ setObjectName(d->canonicalAlias);
qCDebug(MAIN) << "Room canonical alias updated:" << d->canonicalAlias;
emitNamesChanged = true;
break;
diff --git a/room.h b/room.h
index 5b9a1785..d2962d95 100644
--- a/room.h
+++ b/room.h
@@ -40,7 +40,6 @@ namespace QMatrixClient
class MemberSorter;
class LeaveRoomJob;
class RedactEventJob;
- class Room;
class TimelineItem
{
@@ -162,7 +161,7 @@ namespace QMatrixClient
* @brief Produces a disambiguated name for a given user in
* the context of the room
*/
- Q_INVOKABLE QString roomMembername(User* u) const;
+ Q_INVOKABLE QString roomMembername(const User* u) const;
/**
* @brief Produces a disambiguated name for a user with this id in
* the context of the room
diff --git a/user.cpp b/user.cpp
index baa7bc45..8b662acb 100644
--- a/user.cpp
+++ b/user.cpp
@@ -51,7 +51,9 @@ class User::Private
User::User(QString userId, Connection* connection)
: QObject(connection), d(new Private(std::move(userId), connection))
-{ }
+{
+ setObjectName(userId);
+}
User::~User()
{
@@ -74,6 +76,7 @@ void User::updateName(const QString& newName)
if (oldName != newName)
{
d->name = newName;
+ setObjectName(displayname());
emit nameChanged(newName, oldName);
}
}
@@ -127,7 +130,7 @@ QString User::bridged() const {
return d->bridged;
}
-const Avatar& User::avatarObject()
+const Avatar& User::avatarObject() const
{
return d->avatar;
}
diff --git a/user.h b/user.h
index 3df188a1..4f48f20c 100644
--- a/user.h
+++ b/user.h
@@ -58,7 +58,7 @@ namespace QMatrixClient
*/
QString bridged() const;
- const Avatar& avatarObject();
+ const Avatar& avatarObject() const;
Q_INVOKABLE QImage avatar(int dimension);
Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight);