diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-06-07 18:43:42 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 18:43:42 +0900 |
commit | c7c8dd72a4a3c503a2febf428932e0eec4b73aa6 (patch) | |
tree | 6be3b4a49cfbcc691ebd9dbf76cec5e712dea1f6 /user.cpp | |
parent | 28ff47e9cc49c81c1521e4b4e8453cbf28384f44 (diff) | |
parent | 3bad869c1cf9281a27dbcbeebcc05edd41c46dff (diff) | |
download | libquotient-c7c8dd72a4a3c503a2febf428932e0eec4b73aa6.tar.gz libquotient-c7c8dd72a4a3c503a2febf428932e0eec4b73aa6.zip |
Merge pull request #69 from Quiark/pull-bridged-field
Split bridge name into a separate field in user model
Diffstat (limited to 'user.cpp')
-rw-r--r-- | user.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -27,6 +27,7 @@ #include <QtCore/QTimer> #include <QtCore/QDebug> #include <QtGui/QIcon> +#include <QtCore/QRegularExpression> #include <algorithm> using namespace QMatrixClient; @@ -52,6 +53,7 @@ class User::Private bool avatarValid; bool avatarOngoingRequest; QVector<QPixmap> scaledAvatars; + QString bridged; void requestAvatar(); }; @@ -84,6 +86,10 @@ QString User::displayname() const return d->userId; } +QString User::bridged() const { + return d->bridged; +} + QPixmap User::avatar(int width, int height) { return croppedAvatar(width, height); // FIXME: Return an uncropped avatar; @@ -141,6 +147,12 @@ void User::processEvent(Event* event) { const auto oldName = d->name; d->name = e->displayName(); + QRegularExpression reSuffix(" \\((IRC|Gitter)\\)$"); + auto match = reSuffix.match(d->name); + if (match.hasMatch()) { + d->bridged = match.captured(1); + d->name = d->name.left(match.capturedStart(0)); + } emit nameChanged(this, oldName); } if( d->avatarUrl != e->avatarUrl() ) |