aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-27 13:28:35 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-27 13:28:35 +0900
commite74e48507f68e36c289c5dbe4b75f32a6910f3c1 (patch)
tree95fdc4b566d0ad0e15899c439aa004b199ac67b3
parent9be5c32d812a55ca55e1cf80d8e29fe593c85a62 (diff)
downloadlibquotient-e74e48507f68e36c289c5dbe4b75f32a6910f3c1.tar.gz
libquotient-e74e48507f68e36c289c5dbe4b75f32a6910f3c1.zip
User::rawName(); bonus, bring order to doc comments
This new function allows to get the username along with its bridge (basically, undoing the change applied by processEvent for cases when it is undesirable).
-rw-r--r--lib/user.cpp6
-rw-r--r--lib/user.h27
2 files changed, 24 insertions, 9 deletions
diff --git a/lib/user.cpp b/lib/user.cpp
index f469128c..88d20276 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -220,6 +220,12 @@ QString User::name(const Room* room) const
return d->nameForRoom(room);
}
+QString User::rawName(const Room* room) const
+{
+ return d->bridged.isEmpty() ? name(room) :
+ name(room) % " (" % d->bridged % ')';
+}
+
void User::updateName(const QString& newName, const Room* room)
{
updateName(newName, d->nameForRoom(room), room);
diff --git a/lib/user.h b/lib/user.h
index f76f9e0a..f94fbee4 100644
--- a/lib/user.h
+++ b/lib/user.h
@@ -50,24 +50,33 @@ namespace QMatrixClient
/** Get the name chosen by the user
* This may be empty if the user didn't choose the name or cleared
- * it.
- * \sa displayName
+ * it. If the user is bridged, the bridge postfix (such as '(IRC)')
+ * is stripped out. No disambiguation for the room is done.
+ * \sa displayName, rawName
*/
QString name(const Room* room = nullptr) const;
+ /** Get the user name along with the bridge postfix
+ * This function is similar to name() but appends the bridge postfix
+ * (such as '(IRC)') to the user name. No disambiguation is done.
+ * \sa name, displayName
+ */
+ QString rawName(const Room* room = nullptr) const;
+
/** Get the displayed user name
- * This method returns the result of name() if its non-empty;
- * otherwise it returns user id. This is convenient to show a user
- * name outside of a room context. In a room context, user names
- * should be disambiguated.
- * \sa name, id, fullName Room::roomMembername
+ * When \p room is null, this method returns result of name() if
+ * the name is non-empty; otherwise it returns user id.
+ * When \p room is non-null, this call is equivalent to
+ * Room::roomMembername invocation for the user (i.e. the user's
+ * disambiguated room-specific name is returned).
+ * \sa name, id, fullName, Room::roomMembername
*/
QString displayname(const Room* room = nullptr) const;
/** Get user name and id in one string
* The constructed string follows the format 'name (id)'
- * used for users disambiguation in a room context and in other
- * places.
+ * which the spec recommends for users disambiguation in
+ * a room context and in other places.
* \sa displayName, Room::roomMembername
*/
QString fullName(const Room* room = nullptr) const;