From 203a6b61480f726fae341d119f09f9dc83b8829a Mon Sep 17 00:00:00 2001
From: Kitsune Ral <Kitsune-Ral@users.sf.net>
Date: Tue, 1 May 2018 13:52:23 +0900
Subject: Integrate converters with EventPtr partially

So that events can be created from JSON in the same way as all other
types.
---
 lib/events/event.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'lib')

diff --git a/lib/events/event.h b/lib/events/event.h
index d614115a..68e598ad 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -18,15 +18,9 @@
 
 #pragma once
 
-#include <QtCore/QString>
-#include <QtCore/QDateTime>
-#include <QtCore/QJsonObject>
-#include <QtCore/QJsonArray>
-
+#include "converters.h"
 #include "util.h"
 
-#include <memory>
-
 namespace QMatrixClient
 {
     template <typename EventT>
@@ -110,6 +104,14 @@ namespace QMatrixClient
         EventPtr doMakeEvent<Event>(const QJsonObject& obj);
     }
 
+    template <> struct FromJson<EventPtr>
+    {
+        EventPtr operator()(const QJsonValue& jv) const
+        {
+            return makeEvent<Event>(jv.toObject());
+        }
+    };
+
     /**
      * \brief A vector of pointers to events with deserialisation capabilities
      *
-- 
cgit v1.2.3