aboutsummaryrefslogtreecommitdiff
path: root/events/event.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'events/event.cpp')
-rw-r--r--events/event.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/events/event.cpp b/events/event.cpp
index c3e94ce1..9a48108c 100644
--- a/events/event.cpp
+++ b/events/event.cpp
@@ -18,7 +18,7 @@
#include "event.h"
-#include <QtCore/QJsonObject>
+#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
@@ -134,7 +134,8 @@ bool Event::parseJson(const QJsonObject& obj)
}
if( obj.contains("origin_server_ts") )
{
- d->timestamp = QDateTime::fromMSecsSinceEpoch( (quint64) obj.value("origin_server_ts").toDouble(), Qt::UTC );
+ d->timestamp = QDateTime::fromMSecsSinceEpoch(
+ static_cast<qint64>(obj.value("origin_server_ts").toDouble()), Qt::UTC );
} else {
correct = false;
qDebug() << "Event: can't find ts";
@@ -146,3 +147,12 @@ bool Event::parseJson(const QJsonObject& obj)
}
return correct;
}
+
+QList<Event*> QMatrixClient::eventListFromJson(const QJsonArray& json)
+{
+ QList<Event*> l;
+ l.reserve(json.size());
+ for (auto event: json)
+ l.push_back(Event::fromJson(event.toObject()));
+ return l;
+}