From fab6c26770827ce2b8ed8f5d06b3677b75a19cec Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Wed, 25 May 2016 19:45:15 +0900 Subject: Introducing EventList class + minor fix Now you can parse a JSON array into a list of events with a one-liner. Also, fromMSecsSinceEpoch accepts a qint64, not quint64 - fixed the respective cast. --- jobs/roommessagesjob.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'jobs/roommessagesjob.cpp') diff --git a/jobs/roommessagesjob.cpp b/jobs/roommessagesjob.cpp index fc3f5f1e..5a97cc23 100644 --- a/jobs/roommessagesjob.cpp +++ b/jobs/roommessagesjob.cpp @@ -84,12 +84,7 @@ QUrlQuery RoomMessagesJob::query() void RoomMessagesJob::parseJson(const QJsonDocument& data) { QJsonObject obj = data.object(); - QJsonArray chunk = obj.value("chunk").toArray(); - for( const QJsonValue& val: chunk ) - { - Event* event = Event::fromJson(val.toObject()); - d->events.append(event); - } + d->events = eventListFromJson(obj.value("chunk").toArray()); d->end = obj.value("end").toString(); emitResult(); -} \ No newline at end of file +} -- cgit v1.2.3