Fix completions in plain text mode

This commit is contained in:
Nicolas Werner 2021-04-24 09:12:50 +02:00
parent 0619120ab5
commit 6fd485a74a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
2 changed files with 18 additions and 6 deletions

View file

@ -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()]);
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:

View file

@ -4,8 +4,11 @@
#include "UsersModel.h"
#include <QUrl>
#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:
if (UserSettings::instance()->markdown())
return QString("[%1](https://matrix.to/#/%2)")
.arg(displayNames[index.row()])
.arg(userids[index.row()]);
.arg(QString(QUrl::toPercentEncoding(userids[index.row()])));
else
return displayNames[index.row()];
case CompletionModel::SearchRole:
case Qt::DisplayRole:
case Roles::DisplayName: