mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Fix completions in plain text mode
This commit is contained in:
parent
0619120ab5
commit
6fd485a74a
2 changed files with 18 additions and 6 deletions
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue