libQuotient
A Qt library for building matrix clients
Quotient::RoomMember Class Reference

Representation of a user state in a room. More...

#include <roommember.h>

Public Member Functions

 RoomMember ()=default
 
 RoomMember (const Room *room, const RoomMemberEvent *member)
 
bool isEmpty () const
 
bool operator== (const RoomMember &other) const
 
QString id () const
 Get unique stable user id. More...
 
Uri uri () const
 The matrix.to URI for the user. More...
 
bool isLocalMember () const
 Whether this member is the local user. More...
 
Membership membershipState () const
 The membership state of the member. More...
 
QString name () const
 The raw unmodified display name for the user in the given room. More...
 
QString displayName () const
 Get the user display name ready for display. More...
 
QString htmlSafeDisplayName () const
 Get the user display name ready for display. More...
 
QString fullName () const
 Get user name and id in a single string. More...
 
QString htmlSafeFullName () const
 Get user name and id in a single string. More...
 
QString disambiguatedName () const
 Get the disambiguated user name. More...
 
QString htmlSafeDisambiguatedName () const
 Get the disambiguated user name. More...
 
Q_INVOKABLE bool matches (QStringView substr, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Check whether the name or id of the member contains a substring. More...
 
int hue () const
 Hue color component of this user based on the user's Matrix ID. More...
 
qreal hueF () const
 HueF color component of this user based on the user's Matrix ID. More...
 
QColor color () const
 Color based on the user's Matrix ID. More...
 
const AvataravatarObject () const
 
QString avatarMediaId () const
 The mxc URL as a string for the user avatar in the room. More...
 
QUrl avatarUrl () const
 The mxc URL for the user avatar in the room. More...
 
QImage avatar (int width, int height, Avatar::get_callback_t callback) const
 
QImage avatar (int dimension, Avatar::get_callback_t callback) const
 
int powerLevel () const
 The power level of the member. More...
 

Properties

Q_GADGETbool isEmpty
 
QString id
 
Uri uri
 
bool isLocalMember
 
QString displayName
 
QString htmlSafeDisplayName
 
QString fullName
 
QString htmlSafeFullName
 
QString disambiguatedName
 
QString htmlSafeDisambiguatedName
 
int hue
 
qreal hueF
 
QColor color
 
QUrl avatarUrl
 
int powerLevel
 

Detailed Description

Representation of a user state in a room.

The class is intentionally a read-only data object that is effectively a wrapper around an m.room.member event for the desired user. This is designed to provide the data in a format ready for visualizing a user (avatar or name) in the context of the room it was generated in. This means that if a user has set a unique name or avatar for a particular room that is what will be returned.

Note
The RoomMember class is not intended for interacting with the user's profile. For that a Quotient::User object should be obtained from a Quotient::Connection as that has the support functions for modifying profile information.
Warning
RoomMember is a gadget class and should not be kept between syncs. It does not track changes of the member state therefore some member changes (i.e. leaving the room) may render a RoomMember dangling, when calling any of its methods leads to undefined behaviour.
See also
User

Definition at line 32 of file roommember.h.

Constructor & Destructor Documentation

◆ RoomMember() [1/2]

Quotient::RoomMember::RoomMember ( )
default

◆ RoomMember() [2/2]

Quotient::RoomMember::RoomMember ( const Room room,
const RoomMemberEvent member 
)
explicit

Member Function Documentation

◆ avatar() [1/2]

QImage Quotient::RoomMember::avatar ( int  dimension,
Avatar::get_callback_t  callback 
) const

◆ avatar() [2/2]

QImage Quotient::RoomMember::avatar ( int  width,
int  height,
Avatar::get_callback_t  callback 
) const

◆ avatarMediaId()

QString Quotient::RoomMember::avatarMediaId ( ) const

The mxc URL as a string for the user avatar in the room.

This can be empty if none set.

◆ avatarObject()

const Avatar& Quotient::RoomMember::avatarObject ( ) const

◆ avatarUrl()

QUrl Quotient::RoomMember::avatarUrl ( ) const

The mxc URL for the user avatar in the room.

This can be empty if none set.

◆ color()

QColor Quotient::RoomMember::color ( ) const

Color based on the user's Matrix ID.

See https://github.com/quotient-im/libQuotient/wiki/User-color-coding-standard-draft-proposal for the methodology.

◆ disambiguatedName()

QString Quotient::RoomMember::disambiguatedName ( ) const

Get the disambiguated user name.

This function always aims to return something that can be displayed in a UI, so if no display name is set the just user's Matrix ID will be returned. The output is equivalent to fullName() if there is another user in the room with the same name. Otherwise it is equivalent to displayName().

The output is sanitized and suitable for a plain text field. For a rich field use htmlSafeDisambiguatedName().

See also
htmlSafeDisambiguatedName(), fullName(), displayName()

◆ displayName()

QString Quotient::RoomMember::displayName ( ) const

Get the user display name ready for display.

This function always aims to return something that can be displayed in a UI, so if no display name is set the user's Matrix ID will be returned.

The output is sanitized and suitable for a plain text field. For a rich field use htmlSafeDisplayName().

See also
htmlSafeDisplayName()

◆ fullName()

QString Quotient::RoomMember::fullName ( ) const

Get user name and id in a single string.

This function always aims to return something that can be displayed in a UI, so if no display name is set the just user's Matrix ID will be returned. The constructed string follows the format 'name (id)' which the spec recommends for users disambiguation in a room context and in other places.

The output is sanitized and suitable for a plain text field. For a rich field use htmlSafeFullName().

See also
htmlSafeFullName()

◆ htmlSafeDisambiguatedName()

QString Quotient::RoomMember::htmlSafeDisambiguatedName ( ) const

Get the disambiguated user name.

This function always aims to return something that can be displayed in a UI, so if no display name is set the just user's Matrix ID will be returned. The output is equivalent to htmlSafeFullName() if there is another user in the room with the same name. Otherwise it is equivalent to htmlSafeDisplayName().

The output is sanitized and html escaped ready for a rich text field. For a plain field use disambiguatedName().

See also
disambiguatedName(), htmlSafeFullName(), htmlSafeDisplayName()

◆ htmlSafeDisplayName()

QString Quotient::RoomMember::htmlSafeDisplayName ( ) const

Get the user display name ready for display.

This function always aims to return something that can be displayed in a UI, so if no display name is set the user's Matrix ID will be returned.

The output is sanitized and html escaped ready for a rich text field. For a plain field use displayName().

See also
displayName()

◆ htmlSafeFullName()

QString Quotient::RoomMember::htmlSafeFullName ( ) const

Get user name and id in a single string.

This function always aims to return something that can be displayed in a UI, so if no display name is set the just user's Matrix ID will be returned. The constructed string follows the format 'name (id)' which the spec recommends for users disambiguation in a room context and in other places.

The output is sanitized and html escaped ready for a rich text field. For a plain field use fullName().

See also
fullName()

◆ hue()

int Quotient::RoomMember::hue ( ) const

Hue color component of this user based on the user's Matrix ID.

The implementation is based on XEP-0392: https://xmpp.org/extensions/xep-0392.html Naming and ranges are the same as QColor's hue methods: https://doc.qt.io/qt-5/qcolor.html#integer-vs-floating-point-precision

◆ hueF()

qreal Quotient::RoomMember::hueF ( ) const

HueF color component of this user based on the user's Matrix ID.

The implementation is based on XEP-0392: https://xmpp.org/extensions/xep-0392.html Naming and ranges are the same as QColor's hue methods: https://doc.qt.io/qt-5/qcolor.html#integer-vs-floating-point-precision

◆ id()

QString Quotient::RoomMember::id ( ) const

Get unique stable user id.

The Matrix user ID is generated by the server and is never changed.

◆ isEmpty()

bool Quotient::RoomMember::isEmpty ( ) const
inline

Definition at line 55 of file roommember.h.

◆ isLocalMember()

bool Quotient::RoomMember::isLocalMember ( ) const

Whether this member is the local user.

◆ matches()

Q_INVOKABLE bool Quotient::RoomMember::matches ( QStringView  substr,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Check whether the name or id of the member contains a substring.

This is useful for a predicate to filter room members.

See also
MemberMatcher

◆ membershipState()

Membership Quotient::RoomMember::membershipState ( ) const

The membership state of the member.

◆ name()

QString Quotient::RoomMember::name ( ) const

The raw unmodified display name for the user in the given room.

The value will be empty if no display name has been set.

Warning
This value is not sanitized or HTML escape so use appropriately. For ready to display values use displayName() or fullName() for plain text and htmlSafeDisplayName() or htmlSafeFullName() fo rich text.
See also
displayName(), htmlSafeDisplayName(), fullName(), htmlSafeFullName()

◆ operator==()

bool Quotient::RoomMember::operator== ( const RoomMember other) const

◆ powerLevel()

int Quotient::RoomMember::powerLevel ( ) const

The power level of the member.

This is in the context of the current room. Will return the default power level for the room if not specifically set.

◆ uri()

Uri Quotient::RoomMember::uri ( ) const

The matrix.to URI for the user.

Typically used when you want to visit a user (see Quotient::UriResolverBase::visitResource()).

See also
Quotient::UriResolverBase::visitResource()

Property Documentation

◆ avatarUrl

QUrl Quotient::RoomMember::avatarUrl
read

Definition at line 33 of file roommember.h.

◆ color

QColor Quotient::RoomMember::color
read

Definition at line 33 of file roommember.h.

◆ disambiguatedName

QString Quotient::RoomMember::disambiguatedName
read

Definition at line 33 of file roommember.h.

◆ displayName

QString Quotient::RoomMember::displayName
read

Definition at line 33 of file roommember.h.

◆ fullName

QString Quotient::RoomMember::fullName
read

Definition at line 33 of file roommember.h.

◆ htmlSafeDisambiguatedName

QString Quotient::RoomMember::htmlSafeDisambiguatedName
read

Definition at line 33 of file roommember.h.

◆ htmlSafeDisplayName

QString Quotient::RoomMember::htmlSafeDisplayName
read

Definition at line 33 of file roommember.h.

◆ htmlSafeFullName

QString Quotient::RoomMember::htmlSafeFullName
read

Definition at line 33 of file roommember.h.

◆ hue

int Quotient::RoomMember::hue
read

Definition at line 33 of file roommember.h.

◆ hueF

qreal Quotient::RoomMember::hueF
read

Definition at line 33 of file roommember.h.

◆ id

QString Quotient::RoomMember::id
read

Definition at line 33 of file roommember.h.

◆ isEmpty

Q_GADGETbool Quotient::RoomMember::isEmpty
read

Definition at line 33 of file roommember.h.

◆ isLocalMember

bool Quotient::RoomMember::isLocalMember
read

Definition at line 33 of file roommember.h.

◆ powerLevel

int Quotient::RoomMember::powerLevel
read

Definition at line 33 of file roommember.h.

◆ uri

Uri Quotient::RoomMember::uri
read

Definition at line 33 of file roommember.h.


The documentation for this class was generated from the following file: