summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-12 17:37:45 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-12 17:37:45 (GMT)
commit4e97f5be53e8981c626a8ac9caa74f3406a040fd (patch)
treeeb21e7828c5817bc9671f64b1cb404f75dd10348
parentd11cdb14ab2d672538cdc051ec97a2f66def5281 (diff)
Port DeclarativeDataPlugin from QtScript to QJson* -> no more Qt5Script dep
With QJson support in Qt5Core, the dependency on Qt5Script can be avoided (besides Qt5Script being deprecated). This ports the last active code to use QJson* classes instead of the QScript* ones. The port of DeclarativeDataPlugin is done blindly though, as the code cannot be tested currently, because the "datalayers" property of the MarbleQuickItem class was dropped in the Qt5 port.
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/apps/behaim/CMakeLists.txt1
-rw-r--r--src/apps/marble-maps/CMakeLists.txt1
-rw-r--r--src/lib/marble/declarative/CMakeLists.txt2
-rw-r--r--src/lib/marble/declarative/DeclarativeDataPlugin.cpp23
5 files changed, 12 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 361441c..99a095f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -89,7 +89,6 @@ find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Network ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Test ${REQUIRED_QT_VERSION} REQUIRED)
-find_package(Qt5Script ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Svg ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Sql ${REQUIRED_QT_VERSION} REQUIRED)
diff --git a/src/apps/behaim/CMakeLists.txt b/src/apps/behaim/CMakeLists.txt
index 1a0149b..5991e40 100644
--- a/src/apps/behaim/CMakeLists.txt
+++ b/src/apps/behaim/CMakeLists.txt
@@ -20,7 +20,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL Android)
Qt5::Widgets
Qt5::PrintSupport
Qt5::Network
- Qt5::Script
Qt5::Sql
Qt5::Svg
Qt5::Location
diff --git a/src/apps/marble-maps/CMakeLists.txt b/src/apps/marble-maps/CMakeLists.txt
index 5e27a26..d0f3434 100644
--- a/src/apps/marble-maps/CMakeLists.txt
+++ b/src/apps/marble-maps/CMakeLists.txt
@@ -20,7 +20,6 @@ if (CMAKE_SYSTEM_NAME STREQUAL Android)
Qt5::Widgets
Qt5::PrintSupport
Qt5::Network
- Qt5::Script
Qt5::Sql
Qt5::Svg
Qt5::Location
diff --git a/src/lib/marble/declarative/CMakeLists.txt b/src/lib/marble/declarative/CMakeLists.txt
index 73d52d5..86660e4 100644
--- a/src/lib/marble/declarative/CMakeLists.txt
+++ b/src/lib/marble/declarative/CMakeLists.txt
@@ -44,8 +44,6 @@ target_link_libraries( marbledeclarative
LINK_PUBLIC
marblewidget
Qt5::Quick
- LINK_PRIVATE
- Qt5::Script
)
if(Qt5Positioning_FOUND)
target_link_libraries( marbledeclarative
diff --git a/src/lib/marble/declarative/DeclarativeDataPlugin.cpp b/src/lib/marble/declarative/DeclarativeDataPlugin.cpp
index dfbecd0..0d3c011 100644
--- a/src/lib/marble/declarative/DeclarativeDataPlugin.cpp
+++ b/src/lib/marble/declarative/DeclarativeDataPlugin.cpp
@@ -20,8 +20,6 @@
#include <QAbstractListModel>
#include <QMetaObject>
#include <QMetaProperty>
-#include <QScriptValue>
-#include <QScriptValueIterator>
#include <QIcon>
using namespace Marble;
@@ -123,9 +121,11 @@ void DeclarativeDataPluginPrivate::parseObject( QObject *object )
for( int i = 0; i < meta->methodCount(); ++i ) {
if( meta->method(i).methodSignature() == "get(int)" ) {
for( int j=0; j < count; ++j ) {
- QScriptValue value;
- meta->method(i).invoke( object, Qt::AutoConnection, Q_RETURN_ARG( QScriptValue , value), Q_ARG( int, j ) );
- QObject * propertyObject = value.toQObject();
+ QVariant value;
+ meta->method(i).invoke(object, Qt::AutoConnection, Q_RETURN_ARG(QVariant, value), Q_ARG(int, j));
+
+ // TODO: does this casting to QObject work? needs testing!
+ QObject * propertyObject = value.value<QObject*>();
GeoDataCoordinates coordinates;
DeclarativeDataPluginItem * item = new DeclarativeDataPluginItem( q );
if ( propertyObject ) {
@@ -134,11 +134,12 @@ void DeclarativeDataPluginPrivate::parseObject( QObject *object )
QVariant const value = propertyObject->metaObject()->property( k ).read( propertyObject );
parseChunk( item, coordinates, propertyName, value );
}
- } else {
- QScriptValueIterator it( value );
- while ( it.hasNext() ) {
- it.next();
- parseChunk( item, coordinates, it.name(), it.value().toVariant() );
+ } else if (value.canConvert<QVariantHash>()) {
+ QAssociativeIterable iterable = value.value<QAssociativeIterable>();
+ QAssociativeIterable::const_iterator it = iterable.begin();
+ const QAssociativeIterable::const_iterator end = iterable.end();
+ for ( ; it != end; ++it) {
+ parseChunk(item, coordinates, it.key().toString(), it.value());
}
}
addItem( item, coordinates );
@@ -362,7 +363,7 @@ void DeclarativeDataPlugin::setDeclarativeModel( const QVariant &model )
QObject* object = model.value<QObject*>();
if( qobject_cast< QAbstractListModel* >( object ) ) {
d->parseListModel( qobject_cast< QAbstractListModel *>( object ) );
- } else {
+ } else if (object) {
d->parseObject( object );
}