summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-11 02:18:31 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-11 02:33:49 (GMT)
commit2fbf41d031b734ee2bb1046aca2e25ed15406450 (patch)
tree1595c3d1e4592ee3a2fae8309eddbedb1e72435d
parent243317e06dcdf963b581b79b98d9c65373717c2c (diff)
Port OpenCachingComPlugin from QtScript to QJson*
-rw-r--r--src/plugins/render/opencachingcom/CMakeLists.txt2
-rw-r--r--src/plugins/render/opencachingcom/OpenCachingComItem.cpp10
-rw-r--r--src/plugins/render/opencachingcom/OpenCachingComModel.cpp10
3 files changed, 6 insertions, 16 deletions
diff --git a/src/plugins/render/opencachingcom/CMakeLists.txt b/src/plugins/render/opencachingcom/CMakeLists.txt
index 0af100e..e377fd5 100644
--- a/src/plugins/render/opencachingcom/CMakeLists.txt
+++ b/src/plugins/render/opencachingcom/CMakeLists.txt
@@ -17,7 +17,5 @@ QT_WRAP_UI(my_SRCS ${cachedetailsdialog_UI})
qt_add_resources(my_SRCS opencachingcom.qrc)
-set( OpenCachingComPlugin_LIBS Qt5::Script )
-
MARBLE_ADD_PLUGIN( OpenCachingComPlugin ${my_SRCS} )
diff --git a/src/plugins/render/opencachingcom/OpenCachingComItem.cpp b/src/plugins/render/opencachingcom/OpenCachingComItem.cpp
index 27af976..fc9bb01 100644
--- a/src/plugins/render/opencachingcom/OpenCachingComItem.cpp
+++ b/src/plugins/render/opencachingcom/OpenCachingComItem.cpp
@@ -26,9 +26,8 @@
#include <QDialog>
#include <QDateTime>
#include <QFile>
-#include <QScriptEngine>
-#include <QScriptValue>
#include <QDesktopServices>
+#include <QJsonDocument>
#include <QDebug>
@@ -281,11 +280,8 @@ void OpenCachingComItem::addDownloadedFile( const QString &url, const QString &t
return;
}
- QScriptEngine engine;
-
- // Qt requires parentheses around json code
- QScriptValue data = engine.evaluate(QLatin1Char('(') + QString::fromUtf8(file.readAll()) + QLatin1Char(')'));
- QVariantMap cache = data.toVariant().toMap();
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll());
+ QVariantMap cache = jsonDoc.toVariant().toMap();
m_cache["description"] = cache["description"];
m_cache["logs"] = cache["logs"];
diff --git a/src/plugins/render/opencachingcom/OpenCachingComModel.cpp b/src/plugins/render/opencachingcom/OpenCachingComModel.cpp
index 2c721f6..ce1a82c 100644
--- a/src/plugins/render/opencachingcom/OpenCachingComModel.cpp
+++ b/src/plugins/render/opencachingcom/OpenCachingComModel.cpp
@@ -19,8 +19,7 @@
#include <QDebug>
#include <QString>
#include <QUrl>
-#include <QScriptEngine>
-#include <QScriptValue>
+#include <QJsonDocument>
namespace Marble {
@@ -89,11 +88,8 @@ void OpenCachingComModel::getAdditionalItems( const GeoDataLatLonAltBox& box, qi
void OpenCachingComModel::parseFile( const QByteArray& file )
{
- QScriptEngine engine;
-
- // Qt requires parentheses around json code
- QScriptValue data = engine.evaluate(QLatin1Char('(') + QString::fromUtf8(file) + QLatin1Char(')'));
- QVariantList caches = data.toVariant().toList();
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(file);
+ QVariantList caches = jsonDoc.toVariant().toList();
// qDebug()<<"parsing "<<caches.size()<<" items";
QList<AbstractDataPluginItem*> items;