Better rich reply.
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include "csapi/joining.h"
|
||||
#include "csapi/logout.h"
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
@@ -242,3 +244,7 @@ int Controller::dpi() {
|
||||
void Controller::setDpi(int dpi) {
|
||||
SettingsGroup("Interface").setValue("dpi", dpi);
|
||||
}
|
||||
|
||||
QString Controller::removeReply(const QString& text) {
|
||||
return utils::removeReply(text);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ class Controller : public QObject {
|
||||
void loadSettings();
|
||||
void saveSettings() const;
|
||||
|
||||
Q_INVOKABLE QString removeReply(const QString& text);
|
||||
|
||||
private slots:
|
||||
void invokeLogin();
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const {
|
||||
const auto &evt = isPending ? **pendingIt : **timelineIt;
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return utils::eventToString(evt, m_currentRoom, Qt::RichText);
|
||||
return utils::removeReply(utils::eventToString(evt, m_currentRoom, Qt::RichText));
|
||||
}
|
||||
|
||||
if (role == MessageRole) {
|
||||
@@ -389,7 +389,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const {
|
||||
case ReplyEventIdRole:
|
||||
return replyEventId;
|
||||
case ReplyDisplayRole:
|
||||
return utils::eventToString(replyEvt, m_currentRoom, Qt::RichText);
|
||||
return utils::removeReply(utils::eventToString(replyEvt, m_currentRoom, Qt::RichText));
|
||||
case ReplyAuthorRole:
|
||||
return QVariant::fromValue(
|
||||
m_currentRoom->user(replyEvt.senderId()));
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
QString utils::removeReply(const QString& text) {
|
||||
QString result(text);
|
||||
return result.remove(utils::removeReplyRegex);
|
||||
result.remove(utils::removeRichReplyRegex);
|
||||
result.remove(utils::removeReplyRegex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
namespace utils {
|
||||
const QRegExp removeReplyRegex{"> <.*>.*\\n\\n"};
|
||||
const QRegExp removeRichReplyRegex{"<mx-reply>.*</mx-reply>"};
|
||||
|
||||
QString removeReply(const QString& text);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user