aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-07-30 21:32:25 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-07-30 21:32:25 +0200
commit5010a78505a1a89b60cd5d3102e78717567354dd (patch)
tree8778fc1d95416fb228631ab8a682c876be2d6c1d
parenta4bcc4c95768e919d6b37fa3593104d71ad8ae22 (diff)
downloadlibquotient-5010a78505a1a89b60cd5d3102e78717567354dd.tar.gz
libquotient-5010a78505a1a89b60cd5d3102e78717567354dd.zip
User: minor cleanup; doc-comments
-rw-r--r--lib/user.cpp21
-rw-r--r--lib/user.h15
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index 6e377de8..b610573d 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -45,12 +45,9 @@ class User::Private {
public:
static Avatar makeAvatar(QUrl url) { return Avatar(move(url)); }
- Private(QString userId)
- : userId(move(userId))
- , hueF(stringToHueF(this->userId))
- {}
+ Private(QString userId) : id(move(userId)), hueF(stringToHueF(id)) { }
- QString userId;
+ QString id;
QString mostUsedName;
QMultiHash<QString, const Room*> otherNames;
@@ -200,14 +197,14 @@ Connection* User::connection() const
User::~User() = default;
-QString User::id() const { return d->userId; }
+QString User::id() const { return d->id; }
bool User::isGuest() const
{
- Q_ASSERT(!d->userId.isEmpty() && d->userId.startsWith('@'));
- auto it = std::find_if_not(d->userId.begin() + 1, d->userId.end(),
+ Q_ASSERT(!d->id.isEmpty() && d->id.startsWith('@'));
+ auto it = std::find_if_not(d->id.begin() + 1, d->id.end(),
[](QChar c) { return c.isDigit(); });
- Q_ASSERT(it != d->userId.end());
+ Q_ASSERT(it != d->id.end());
return *it == ':';
}
@@ -293,7 +290,7 @@ bool User::isIgnored() const { return connection()->isIgnored(this); }
void User::Private::setAvatarOnServer(QString contentUri, User* q)
{
- auto* j = q->connection()->callApi<SetAvatarUrlJob>(userId, contentUri);
+ auto* j = q->connection()->callApi<SetAvatarUrlJob>(id, contentUri);
connect(j, &BaseJob::success, q,
[=] { q->updateAvatarUrl(contentUri, avatarUrlForRoom(nullptr)); });
}
@@ -304,13 +301,13 @@ QString User::displayname(const Room* room) const
return room->roomMembername(this);
const auto name = d->nameForRoom(nullptr);
- return name.isEmpty() ? d->userId : name;
+ return name.isEmpty() ? d->id : name;
}
QString User::fullName(const Room* room) const
{
const auto name = d->nameForRoom(room);
- return name.isEmpty() ? d->userId : name % " (" % d->userId % ')';
+ return name.isEmpty() ? id() : name % " (" % id() % ')';
}
QString User::bridged() const { return {}; }
diff --git a/lib/user.h b/lib/user.h
index fdad08bb..e4328f1d 100644
--- a/lib/user.h
+++ b/lib/user.h
@@ -21,7 +21,6 @@
#include "avatar.h"
#include <QtCore/QObject>
-#include <QtCore/QString>
namespace Quotient {
class Connection;
@@ -109,6 +108,10 @@ public:
int hue() const;
qreal hueF() const;
+ /// Get a reference to a user avatar object for a given room
+ /*! This reference should be considered short-lived: processing the next
+ * room member event for this user may (or may not) invalidate it.
+ */
const Avatar& avatarObject(const Room* room = nullptr) const;
Q_INVOKABLE QImage avatar(int dimension,
const Quotient::Room* room = nullptr);
@@ -135,16 +138,16 @@ public slots:
bool setAvatar(const QString& fileName);
/** Upload contents of the QIODevice and set that as an avatar */
bool setAvatar(QIODevice* source);
- /** Create or find a direct chat with this user
- * The resulting chat is returned asynchronously via
+ /// Create or find a direct chat with this user
+ /*! The resulting chat is returned asynchronously via
* Connection::directChatAvailable()
*/
void requestDirectChat();
- /** Add the user to the ignore list */
+ /// Add the user to the ignore list
void ignore();
- /** Remove the user from the ignore list */
+ /// Remove the user from the ignore list
void unmarkIgnore();
- /** Check whether the user is in ignore list */
+ /// Check whether the user is in ignore list
bool isIgnored() const;
signals: