diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml
index c5c3fde0..8f9090e3 100644
--- a/resources/qml/TimelineRow.qml
+++ b/resources/qml/TimelineRow.qml
@@ -14,12 +14,23 @@ RowLayout {
anchors.left: parent.left
anchors.right: parent.right
- implicitHeight: contentItem.childrenRect.height
+ implicitHeight: contentItem.height
- MessageDelegate {
+ Column {
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
id: contentItem
+
+ //property var replyTo: model.replyTo
+
+ //Text {
+ // property int idx: timelineManager.timeline.idToIndex(replyTo)
+ // text: "" + (idx != -1 ? timelineManager.timeline.data(timelineManager.timeline.index(idx, 0), 2) : "nothing")
+ //}
+ MessageDelegate {
+ width: parent.width
+ height: childrenRect.height
+ }
}
StatusIndicator {
diff --git a/src/Utils.cpp b/src/Utils.cpp
index e27bc995..8f9e0643 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -366,7 +366,7 @@ utils::getFormattedQuoteBody(const RelatedInfo &related, const QString &html)
{
return QString("In reply "
- "to* %4
%4
%5
")
.arg(related.room,
QString::fromStdString(related.related_event),
@@ -382,9 +382,6 @@ utils::getQuoteBody(const RelatedInfo &related)
using MsgType = mtx::events::MessageType;
switch (related.type) {
- case MsgType::Text: {
- return markdownToHtml(related.quoted_body);
- }
case MsgType::File: {
return QString(QCoreApplication::translate("utils", "sent a file."));
}
diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp
index bdb3ea6f..b2b6f803 100644
--- a/src/timeline2/TimelineModel.cpp
+++ b/src/timeline2/TimelineModel.cpp
@@ -13,6 +13,8 @@
#include "Utils.h"
#include "dialogs/RawMessage.h"
+Q_DECLARE_METATYPE(QModelIndex)
+
namespace {
template
QString
@@ -80,12 +82,6 @@ eventFormattedBody(const mtx::events::RoomEvent &e)
{
auto temp = e.content.formatted_body;
if (!temp.empty()) {
- auto pos = temp.find("");
- if (pos != std::string::npos)
- temp.erase(pos, std::string("").size());
- pos = temp.find("");
- if (pos != std::string::npos)
- temp.erase(pos, std::string("").size());
return QString::fromStdString(temp);
} else {
return QString::fromStdString(e.content.body).toHtmlEscaped().replace("\n", "
");
@@ -182,6 +178,21 @@ eventMimeType(const mtx::events::RoomEvent &e)
return QString::fromStdString(e.content.info.mimetype);
}
+template
+QString
+eventRelatesTo(const mtx::events::Event &)
+{
+ return QString();
+}
+template
+auto
+eventRelatesTo(const mtx::events::RoomEvent &e) -> std::enable_if_t<
+ std::is_same::value,
+ QString>
+{
+ return QString::fromStdString(e.content.relates_to.in_reply_to.event_id);
+}
+
template
qml_mtx_events::EventType
toRoomEventType(const mtx::events::Event &e)
@@ -383,6 +394,7 @@ TimelineModel::roleNames() const
{Id, "id"},
{State, "state"},
{IsEncrypted, "isEncrypted"},
+ {ReplyTo, "replyTo"},
};
}
int
@@ -450,8 +462,12 @@ TimelineModel::data(const QModelIndex &index, int role) const
return QVariant(utils::replaceEmoji(boost::apply_visitor(
[](const auto &e) -> QString { return eventBody(e); }, event)));
case FormattedBody:
- return QVariant(utils::replaceEmoji(boost::apply_visitor(
- [](const auto &e) -> QString { return eventFormattedBody(e); }, event)));
+ return QVariant(
+ utils::replaceEmoji(
+ boost::apply_visitor(
+ [](const auto &e) -> QString { return eventFormattedBody(e); }, event))
+ .remove("")
+ .remove(""));
case Url:
return QVariant(boost::apply_visitor(
[](const auto &e) -> QString { return eventUrl(e); }, event));
@@ -501,6 +517,11 @@ TimelineModel::data(const QModelIndex &index, int role) const
return boost::get>(
&tempEvent) != nullptr;
}
+ case ReplyTo: {
+ QString evId = boost::apply_visitor(
+ [](const auto &e) -> QString { return eventRelatesTo(e); }, event);
+ return QVariant(evId);
+ }
default:
return QVariant();
}
@@ -825,8 +846,11 @@ TimelineModel::replyAction(QString id)
event);
related.type = mtx::events::getMessageType(boost::apply_visitor(
[](const auto &e) -> std::string { return eventMsgType(e); }, event));
- related.quoted_body =
- boost::apply_visitor([](const auto &e) -> QString { return eventBody(e); }, event);
+ related.quoted_body = boost::apply_visitor(
+ [](const auto &e) -> QString { return eventFormattedBody(e); }, event);
+ related.quoted_body.remove(QRegularExpression(
+ ".*", QRegularExpression::DotMatchesEverythingOption));
+ nhlog::ui()->debug("after replacement: {}", related.quoted_body.toStdString());
related.room = room_id_;
if (related.quoted_body.isEmpty())
diff --git a/src/timeline2/TimelineModel.h b/src/timeline2/TimelineModel.h
index 1ed6e72c..31e41315 100644
--- a/src/timeline2/TimelineModel.h
+++ b/src/timeline2/TimelineModel.h
@@ -139,6 +139,7 @@ public:
Id,
State,
IsEncrypted,
+ ReplyTo,
};
QHash roleNames() const override;