From 6fd485a74a9ffcfd006e4bfefa05052d48effb4b Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sat, 24 Apr 2021 09:12:50 +0200 Subject: [PATCH] Fix completions in plain text mode --- src/RoomsModel.cpp | 12 +++++++++--- src/UsersModel.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/RoomsModel.cpp b/src/RoomsModel.cpp index 5df756f1..80f13756 100644 --- a/src/RoomsModel.cpp +++ b/src/RoomsModel.cpp @@ -8,6 +8,7 @@ #include "Cache_p.h" #include "CompletionModelRoles.h" +#include "UserSettingsPage.h" RoomsModel::RoomsModel(bool showOnlyRoomWithAliases, QObject *parent) : QAbstractListModel(parent) @@ -55,9 +56,14 @@ RoomsModel::data(const QModelIndex &index, int role) const if (hasIndex(index.row(), index.column(), index.parent())) { switch (role) { case CompletionModel::CompletionRole: { - QString percentEncoding = QUrl::toPercentEncoding(roomAliases[index.row()]); - return QString("[%1](https://matrix.to/#/%2)") - .arg(roomAliases[index.row()], percentEncoding); + if (UserSettings::instance()->markdown()) { + QString percentEncoding = + QUrl::toPercentEncoding(roomAliases[index.row()]); + return QString("[%1](https://matrix.to/#/%2)") + .arg(roomAliases[index.row()], percentEncoding); + } else { + return roomAliases[index.row()]; + } } case CompletionModel::SearchRole: case Qt::DisplayRole: diff --git a/src/UsersModel.cpp b/src/UsersModel.cpp index dd77e512..c4379668 100644 --- a/src/UsersModel.cpp +++ b/src/UsersModel.cpp @@ -4,8 +4,11 @@ #include "UsersModel.h" +#include + #include "Cache.h" #include "CompletionModelRoles.h" +#include "UserSettingsPage.h" UsersModel::UsersModel(const std::string &roomId, QObject *parent) : QAbstractListModel(parent) @@ -37,9 +40,12 @@ UsersModel::data(const QModelIndex &index, int role) const if (hasIndex(index.row(), index.column(), index.parent())) { switch (role) { case CompletionModel::CompletionRole: - return QString("[%1](https://matrix.to/#/%2)") - .arg(displayNames[index.row()]) - .arg(userids[index.row()]); + if (UserSettings::instance()->markdown()) + return QString("[%1](https://matrix.to/#/%2)") + .arg(displayNames[index.row()]) + .arg(QString(QUrl::toPercentEncoding(userids[index.row()]))); + else + return displayNames[index.row()]; case CompletionModel::SearchRole: case Qt::DisplayRole: case Roles::DisplayName: