summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-11 01:29:11 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-11 02:19:19 (GMT)
commit6fc39be28efede63c67a18de1fad180be257cf40 (patch)
tree15a4f55f3b26f6e7dee04e868224c8a9c360ffca
parent4915d5894b8808b7328317cea9a6895a0764e43d (diff)
Port marblewidget from QtScript to QJson*
-rw-r--r--src/lib/marble/CMakeLists.txt1
-rw-r--r--src/lib/marble/cloudsync/BookmarkSyncManager.cpp22
-rw-r--r--src/lib/marble/cloudsync/OwncloudSyncBackend.cpp33
3 files changed, 25 insertions, 31 deletions
diff --git a/src/lib/marble/CMakeLists.txt b/src/lib/marble/CMakeLists.txt
index 8984dbe..fe4fc78 100644
--- a/src/lib/marble/CMakeLists.txt
+++ b/src/lib/marble/CMakeLists.txt
@@ -381,7 +381,6 @@ target_link_libraries(marblewidget
Qt5::Widgets
LINK_PRIVATE
Qt5::Svg
- Qt5::Script
Qt5::PrintSupport
Qt5::Concurrent
)
diff --git a/src/lib/marble/cloudsync/BookmarkSyncManager.cpp b/src/lib/marble/cloudsync/BookmarkSyncManager.cpp
index 2928a55..819a0e2 100644
--- a/src/lib/marble/cloudsync/BookmarkSyncManager.cpp
+++ b/src/lib/marble/cloudsync/BookmarkSyncManager.cpp
@@ -25,8 +25,8 @@
#include <QFile>
#include <QBuffer>
-#include <QScriptValue>
-#include <QScriptEngine>
+#include <QJsonDocument>
+#include <QJsonObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QTimer>
@@ -707,11 +707,10 @@ void BookmarkSyncManager::Private::saveDownloadedToCache( const QByteArray &kml
void BookmarkSyncManager::Private::parseTimestamp()
{
- QString response = m_timestampReply->readAll();
- QScriptEngine engine;
- QScriptValue parsedResponse = engine.evaluate( QString( "(%0)" ).arg( response ) );
- QString timestamp = parsedResponse.property( "data" ).toString();
- m_cloudTimestamp = timestamp;
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(m_timestampReply->readAll());
+ QJsonValue dataValue = jsonDoc.object().value(QStringLiteral("data"));
+
+ m_cloudTimestamp = dataValue.toString();
mDebug() << "Remote bookmark timestamp is " << m_cloudTimestamp;
continueSynchronization();
}
@@ -795,11 +794,10 @@ void BookmarkSyncManager::Private::completeMerge()
void BookmarkSyncManager::Private::completeUpload()
{
- QString response = m_uploadReply->readAll();
- QScriptEngine engine;
- QScriptValue parsedResponse = engine.evaluate( QString( "(%0)" ).arg( response ) );
- QString timestamp = parsedResponse.property( "data" ).toString();
- m_cloudTimestamp = timestamp;
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(m_uploadReply->readAll());
+ QJsonValue dataValue = jsonDoc.object().value(QStringLiteral("data"));
+
+ m_cloudTimestamp = dataValue.toString();
mDebug() << "Uploaded bookmarks to remote server. Timestamp is " << m_cloudTimestamp;
copyLocalToCache();
emit m_q->syncComplete();
diff --git a/src/lib/marble/cloudsync/OwncloudSyncBackend.cpp b/src/lib/marble/cloudsync/OwncloudSyncBackend.cpp
index d445554..8588235 100644
--- a/src/lib/marble/cloudsync/OwncloudSyncBackend.cpp
+++ b/src/lib/marble/cloudsync/OwncloudSyncBackend.cpp
@@ -29,10 +29,11 @@
#include "GeoDataExtendedData.h"
#include <QNetworkAccessManager>
-#include <QScriptValueIterator>
#include <QNetworkRequest>
#include <QNetworkReply>
-#include <QScriptEngine>
+#include <QJsonDocument>
+#include <QJsonArray>
+#include <QJsonObject>
#include <QFileInfo>
#include <QBuffer>
#include <QDir>
@@ -337,25 +338,21 @@ void OwncloudSyncBackend::cancelUpload()
void OwncloudSyncBackend::prepareRouteList()
{
- QString result = d->m_routeListReply->readAll();
-
- QScriptEngine engine;
- QScriptValue response = engine.evaluate( QString( "(%0)" ).arg( result ) );
- QScriptValue routes = response.property( "data" );
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(d->m_routeListReply->readAll());
+ QJsonValue dataValue = jsonDoc.object().value(QStringLiteral("data"));
d->m_routeList.clear();
-
- if( routes.isArray() ) {
- QScriptValueIterator iterator( routes );
-
- while( iterator.hasNext() ) {
- iterator.next();
-
+
+ if (dataValue.isArray()) {
+ QJsonArray dataArray = dataValue.toArray();
+ for (int index = 0; index < dataArray.size(); ++index) {
+ QJsonObject dataObject = dataArray[index].toObject();
+
RouteItem route;
- route.setIdentifier( iterator.value().property( "timestamp" ).toString() );
- route.setName ( iterator.value().property( "name" ).toString() );
- route.setDistance( iterator.value().property( "distance" ).toString() );
- route.setDuration( iterator.value().property( "duration" ).toString() );
+ route.setIdentifier(dataObject.value(QStringLiteral("timestamp")).toString());
+ route.setName(dataObject.value(QStringLiteral("name")).toString() );
+ route.setDistance(dataObject.value(QStringLiteral("distance")).toString());
+ route.setDuration(dataObject.value(QStringLiteral("duration")).toString());
route.setPreviewUrl( endpointUrl( d->m_routePreviewEndpoint, route.identifier() ) );
route.setOnCloud( true );