summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-09-08 15:26:46 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:14 +0100
commit7aca8a94304b47904f214325b969c115944296c8 (patch)
tree2b52c4c4484739052f1675381ef01515112aa77a /src
parentImplement basic ImageMessages in qml timeline (diff)
downloadnheko-7aca8a94304b47904f214325b969c115944296c8.tar.xz
Reenable view raw message
Diffstat (limited to 'src')
-rw-r--r--src/timeline2/TimelineModel.cpp13
-rw-r--r--src/timeline2/TimelineModel.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp
index 16f1dfe6..5fd54170 100644
--- a/src/timeline2/TimelineModel.cpp
+++ b/src/timeline2/TimelineModel.cpp
@@ -6,6 +6,7 @@
 
 #include "Logging.h"
 #include "Utils.h"
+#include "dialogs/RawMessage.h"
 
 namespace {
 template<class T>
@@ -220,6 +221,7 @@ TimelineModel::roleNames() const
           {Height, "height"},
           {Width, "width"},
           {ProportionalHeight, "proportionalHeight"},
+          {Id, "id"},
         };
 }
 int
@@ -293,7 +295,8 @@ TimelineModel::data(const QModelIndex &index, int role) const
         case ProportionalHeight:
                 return QVariant(boost::apply_visitor(
                   [](const auto &e) -> double { return eventPropHeight(e); }, events.value(id)));
-
+        case Id:
+                return id;
         default:
                 return QVariant();
         }
@@ -417,3 +420,11 @@ TimelineModel::escapeEmoji(QString str) const
 {
         return utils::replaceEmoji(str);
 }
+
+void
+TimelineModel::viewRawMessage(QString id) const
+{
+        std::string ev = utils::serialize_event(events.value(id)).dump(4);
+        auto dialog    = new dialogs::RawMessage(QString::fromStdString(ev));
+        Q_UNUSED(dialog);
+}
diff --git a/src/timeline2/TimelineModel.h b/src/timeline2/TimelineModel.h
index 66d03cf5..02a0c168 100644
--- a/src/timeline2/TimelineModel.h
+++ b/src/timeline2/TimelineModel.h
@@ -86,6 +86,7 @@ public:
                 Height,
                 Width,
                 ProportionalHeight,
+                Id,
         };
 
         QHash<int, QByteArray> roleNames() const override;
@@ -97,6 +98,7 @@ public:
         Q_INVOKABLE QString avatarUrl(QString id) const;
         Q_INVOKABLE QString formatDateSeparator(QDate date) const;
         Q_INVOKABLE QString escapeEmoji(QString str) const;
+        Q_INVOKABLE void viewRawMessage(QString id) const;
 
         void addEvents(const mtx::responses::Timeline &events);