From 41e34a96bf078c4080dd54ed62fa1b1dcc42a17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Pla=CC=81s=CC=8Cil?= Date: Fri, 19 May 2017 18:44:29 +0800 Subject: Split user's bridge (IRC, Gitter) into a separate field in user model object --- user.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'user.cpp') diff --git a/user.cpp b/user.cpp index f2a3a33b..8d37eef6 100644 --- a/user.cpp +++ b/user.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include using namespace QMatrixClient; @@ -52,6 +53,7 @@ class User::Private bool avatarValid; bool avatarOngoingRequest; QVector 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() ) -- cgit v1.2.3