mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
check for empty alias and percent encoding for alias in url
This commit is contained in:
parent
0b6c82dfff
commit
3ea0e79a36
1 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "RoomsModel.h"
|
#include "RoomsModel.h"
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include "Cache_p.h"
|
#include "Cache_p.h"
|
||||||
#include "CompletionModelRoles.h"
|
#include "CompletionModelRoles.h"
|
||||||
|
|
||||||
|
@ -14,7 +16,7 @@ RoomsModel::RoomsModel(bool showOnlyRoomWithAliases, QObject *parent)
|
||||||
auto roomAliasesList = cache::client()->getRoomAliases(r);
|
auto roomAliasesList = cache::client()->getRoomAliases(r);
|
||||||
|
|
||||||
if (showOnlyRoomWithAliases_) {
|
if (showOnlyRoomWithAliases_) {
|
||||||
if (roomAliasesList) {
|
if (roomAliasesList && !roomAliasesList->alias.empty()) {
|
||||||
roomids.push_back(QString::fromStdString(r));
|
roomids.push_back(QString::fromStdString(r));
|
||||||
roomAliases.push_back(
|
roomAliases.push_back(
|
||||||
QString::fromStdString(roomAliasesList->alias));
|
QString::fromStdString(roomAliasesList->alias));
|
||||||
|
@ -44,8 +46,11 @@ RoomsModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (hasIndex(index.row(), index.column(), index.parent())) {
|
if (hasIndex(index.row(), index.column(), index.parent())) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case CompletionModel::CompletionRole:
|
case CompletionModel::CompletionRole: {
|
||||||
return QString("[%1](https://matrix.to/%1)").arg(roomAliases[index.row()]);
|
QString percentEncoding = QUrl::toPercentEncoding(roomAliases[index.row()]);
|
||||||
|
return QString("[%1](https://matrix.to/#/%2)")
|
||||||
|
.arg(roomAliases[index.row()], percentEncoding);
|
||||||
|
}
|
||||||
case CompletionModel::SearchRole:
|
case CompletionModel::SearchRole:
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Roles::RoomAlias:
|
case Roles::RoomAlias:
|
||||||
|
|
Loading…
Reference in a new issue