summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/mapviewer/mapviewer.qml14
-rw-r--r--examples/declarative/places/places.qml8
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativecategory.cpp15
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativecategory_p.h1
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace.cpp11
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplace_p.h1
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp10
-rw-r--r--src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h3
-rw-r--r--src/imports/location/location.cpp1
-rw-r--r--src/imports/location/qdeclarativegeocodemodel.cpp4
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp4
-rw-r--r--src/imports/location/qdeclarativegeoroutemodel.cpp4
-rw-r--r--src/imports/location/qdeclarativegeoserviceprovider.cpp382
-rw-r--r--src/imports/location/qdeclarativegeoserviceprovider_p.h168
-rw-r--r--src/location/maps/qgeocodingmanager.cpp19
-rw-r--r--src/location/maps/qgeocodingmanager.h3
-rw-r--r--src/location/maps/qgeocodingmanagerengine.cpp45
-rw-r--r--src/location/maps/qgeocodingmanagerengine.h8
-rw-r--r--src/location/maps/qgeocodingmanagerengine_p.h3
-rw-r--r--src/location/maps/qgeoroutingmanager.cpp24
-rw-r--r--src/location/maps/qgeoroutingmanager.h3
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.cpp65
-rw-r--r--src/location/maps/qgeoroutingmanagerengine.h6
-rw-r--r--src/location/maps/qgeoroutingmanagerengine_p.h3
-rw-r--r--src/location/maps/qgeoserviceprovider.cpp335
-rw-r--r--src/location/maps/qgeoserviceprovider.h77
-rw-r--r--src/location/maps/qgeoserviceprovider_p.h21
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.cpp19
-rw-r--r--src/location/maps/qgeoserviceproviderfactory.h12
-rw-r--r--src/location/places/qplacemanager.cpp8
-rw-r--r--src/location/places/qplacemanager.h21
-rw-r--r--src/location/places/qplacemanagerengine.cpp9
-rw-r--r--src/location/places/qplacemanagerengine.h2
-rw-r--r--src/plugins/geoservices/nokia/nokia.pro3
-rw-r--r--src/plugins/geoservices/nokia/nokia_plugin.json20
-rw-r--r--src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp16
-rw-r--r--src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp9
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp17
-rw-r--r--src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h9
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp9
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h2
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp7
-rw-r--r--src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h2
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/nokia_places_jsondb.pro3
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/nokia_plugin_jsondb.json14
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.cpp17
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.h10
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp9
-rw-r--r--src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h1
-rw-r--r--tests/auto/declarative_core/tst_plugin.qml96
-rw-r--r--tests/auto/geotestplugin/geotestplugin.json19
-rw-r--r--tests/auto/geotestplugin/geotestplugin.pro3
-rw-r--r--tests/auto/geotestplugin/qgeocodingmanagerengine_test.h2
-rw-r--r--tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h3
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp17
-rw-r--r--tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h10
-rw-r--r--tests/auto/geotestplugin/qplacemanagerengine_test.h6
-rw-r--r--tests/auto/placesplugin_unsupported/placesplugin.json8
-rw-r--r--tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro3
-rw-r--r--tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp17
-rw-r--r--tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h8
-rw-r--r--tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp20
-rw-r--r--tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h1
-rw-r--r--tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json10
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h2
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro3
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp17
-rw-r--r--tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h9
-rw-r--r--tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp19
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h3
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro3
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp17
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h9
-rw-r--r--tests/auto/qgeoroutingmanagerplugins/routing_plugin.json12
-rw-r--r--tests/auto/qplacemanager/tst_qplacemanager.cpp4
-rw-r--r--tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp23
-rw-r--r--tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp7
77 files changed, 983 insertions, 825 deletions
diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml
index c80abb91..05c9acfc 100644
--- a/examples/declarative/mapviewer/mapviewer.qml
+++ b/examples/declarative/mapviewer/mapviewer.qml
@@ -555,12 +555,15 @@ Item {
plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"; parameters: page.parameters}', page)
else
plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin{ name:"' + provider + '"}', page)
- var wanted = (Plugin.MappingFeature | Plugin.GeocodingFeature | Plugin.ReverseGeocodingFeature | Plugin.RoutingFeature)
- if ((plugin.supported & wanted) == wanted) {
+ if (plugin.supportsMapping()
+ && plugin.supportsGeocoding(Plugin.ReverseGeocodingFeature)
+ && plugin.supportsRouting()) {
+
if (map) {
map.destroy()
minimap = null
}
+
map = Qt.createQmlObject ('import QtLocation 5.0;\
import "content/map";\
MapComponent{\
@@ -613,12 +616,13 @@ Item {
function getPlugins(){
var plugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {}', page)
var tempPlugin
- var wanted = (Plugin.MappingFeature | Plugin.GeocodingFeature | Plugin.ReverseGeocodingFeature | Plugin.RoutingFeature)
var myArray = new Array()
for (var i = 0; i<plugin.availableServiceProviders.length; i++){
tempPlugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', page)
- //note this will allocate all the plugin managers and resources
- if ((tempPlugin.supported & wanted) == wanted) {
+
+ if (tempPlugin.supportsMapping()
+ && tempPlugin.supportsGeocoding(Plugin.ReverseGeocodingFeature)
+ && tempPlugin.supportsRouting()) {
myArray.push(tempPlugin.name)
}
}
diff --git a/examples/declarative/places/places.qml b/examples/declarative/places/places.qml
index b98f29c8..481718a6 100644
--- a/examples/declarative/places/places.qml
+++ b/examples/declarative/places/places.qml
@@ -560,10 +560,10 @@ Item {
function createMap(placesPlugin) {
var mapPlugin;
- if (placesPlugin.supported & Plugin.MappingFeature) {
+ if (placesPlugin.supportsMapping()) {
mapPlugin = placesPlugin;
} else {
- mapPlugin = Qt.createQmlObject('import QtLocation 5.0; Plugin { required: Plugin.MappingFeature }', page);
+ mapPlugin = Qt.createQmlObject('import QtLocation 5.0; Plugin { required.mapping: Plugin.AnyMappingFeatures }', page);
}
if (map)
@@ -577,8 +577,8 @@ Item {
var myArray = new Array;
for (var i = 0; i < plugin.availableServiceProviders.length; i++) {
var tempPlugin = Qt.createQmlObject ('import QtLocation 5.0; Plugin {name: "' + plugin.availableServiceProviders[i]+ '"}', page)
- //note this will allocate all the plugin managers and resources
- if (tempPlugin.supported & Plugin.AnyPlacesFeature)
+
+ if (tempPlugin.supportsPlaces())
myArray.push(tempPlugin.name)
}
diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
index f4b5b83c..8496f022 100644
--- a/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativecategory.cpp
@@ -127,6 +127,16 @@ void QDeclarativeCategory::setPlugin(QDeclarativeGeoServiceProvider *plugin)
if (!m_plugin)
return;
+ if (m_plugin->isAttached()) {
+ pluginReady();
+ } else {
+ connect(m_plugin, SIGNAL(attached()),
+ this, SLOT(pluginReady()));
+ }
+}
+
+void QDeclarativeCategory::pluginReady()
+{
QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
QPlaceManager *placeManager = serviceProvider->placeManager();
if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
@@ -428,6 +438,11 @@ QPlaceManager *QDeclarativeCategory::manager()
}
QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
+ if (!serviceProvider) {
+ m_errorString = tr("Plugin not valid");
+ setStatus(Error);
+ return 0;
+ }
QPlaceManager *placeManager = serviceProvider->placeManager();
if (!placeManager) {
m_errorString = tr("Places not supported by %1 plugin.").arg(m_plugin->name());
diff --git a/src/imports/location/declarativeplaces/qdeclarativecategory_p.h b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
index a8ed66c1..ba3a9502 100644
--- a/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativecategory_p.h
@@ -125,6 +125,7 @@ signals:
private slots:
void replyFinished();
+ void pluginReady();
private:
QPlaceManager *manager();
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
index 9617c8f0..e4fb3887 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace.cpp
@@ -230,6 +230,17 @@ void QDeclarativePlace::setPlugin(QDeclarativeGeoServiceProvider *plugin)
m_plugin = plugin;
if (m_complete)
emit pluginChanged();
+
+ if (m_plugin->isAttached()) {
+ pluginReady();
+ } else {
+ connect(m_plugin, SIGNAL(attached()),
+ this, SLOT(pluginReady()));
+ }
+}
+
+void QDeclarativePlace::pluginReady()
+{
QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
QPlaceManager *placeManager = serviceProvider->placeManager();
if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
index a6a78bc7..bc91d8ba 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplace_p.h
@@ -204,6 +204,7 @@ signals:
private slots:
void finished();
void contactsModified(const QString &, const QVariant &);
+ void pluginReady();
private:
void synchronizeCategories();
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
index 043d2221..15e0c099 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceicon.cpp
@@ -198,6 +198,16 @@ void QDeclarativePlaceIcon::setPlugin(QDeclarativeGeoServiceProvider *plugin)
if (!m_plugin)
return;
+ if (m_plugin->isAttached()) {
+ pluginReady();
+ } else {
+ connect(m_plugin, SIGNAL(attached()),
+ this, SLOT(pluginReady()));
+ }
+}
+
+void QDeclarativePlaceIcon::pluginReady()
+{
QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider();
QPlaceManager *placeManager = serviceProvider->placeManager();
if (!placeManager || serviceProvider->error() != QGeoServiceProvider::NoError) {
diff --git a/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h b/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h
index 0b3ec0d6..f06f3438 100644
--- a/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h
+++ b/src/imports/location/declarativeplaces/qdeclarativeplaceicon_p.h
@@ -82,6 +82,9 @@ signals:
void parametersChanged(); //in practice is never emitted since parameters cannot be re-assigned
//the declaration is needed to avoid warnings about non-notifyable properties
+private Q_SLOTS:
+ void pluginReady();
+
private:
QPlaceManager *manager() const;
void initParameters(const QVariantMap &parameterMap);
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 66c9b981..809a6bf2 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -116,6 +116,7 @@ public:
qmlRegisterType<QDeclarativeGeoServiceProvider>(uri, 5, 0, "Plugin");
qmlRegisterType<QDeclarativeGeoServiceProviderParameter>(uri, 5, 0, "PluginParameter");
+ qmlRegisterUncreatableType<QDeclarativeGeoServiceProviderRequirements>(uri, 5, 0, "PluginRequirements", QDeclarativeGeoMapItemBase::tr("PluginRequirements is not intended instantiable by developer"));
qmlRegisterType<QDeclarativeGeoMap>(uri, 5, 0, "Map");
qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase>(uri, 5, 0, "GeoMapItemBase",QDeclarativeGeoMapItemBase::tr("GeoMapItemBase is not intended instantiable by developer."));
diff --git a/src/imports/location/qdeclarativegeocodemodel.cpp b/src/imports/location/qdeclarativegeocodemodel.cpp
index 1a7dfe83..5c4ba148 100644
--- a/src/imports/location/qdeclarativegeocodemodel.cpp
+++ b/src/imports/location/qdeclarativegeocodemodel.cpp
@@ -269,10 +269,10 @@ void QDeclarativeGeocodeModel::setPlugin(QDeclarativeGeoServiceProvider *plugin)
if (!plugin)
return;
- if (plugin_->ready()) {
+ if (plugin_->isAttached()) {
pluginReady();
} else {
- connect(plugin_, SIGNAL(supportedFeaturesChanged(PluginFeatures)),
+ connect(plugin_, SIGNAL(attached()),
this, SLOT(pluginReady()));
}
}
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 9b1b8b6b..d07f8553 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -430,10 +430,10 @@ void QDeclarativeGeoMap::setPlugin(QDeclarativeGeoServiceProvider *plugin)
plugin_ = plugin;
emit pluginChanged(plugin_);
- if (plugin_->ready()) {
+ if (plugin_->isAttached()) {
pluginReady();
} else {
- connect(plugin_, SIGNAL(supportedFeaturesChanged(PluginFeatures)),
+ connect(plugin_, SIGNAL(attached()),
this, SLOT(pluginReady()));
}
}
diff --git a/src/imports/location/qdeclarativegeoroutemodel.cpp b/src/imports/location/qdeclarativegeoroutemodel.cpp
index 5fbe4771..5b8c6935 100644
--- a/src/imports/location/qdeclarativegeoroutemodel.cpp
+++ b/src/imports/location/qdeclarativegeoroutemodel.cpp
@@ -265,10 +265,10 @@ void QDeclarativeGeoRouteModel::setPlugin(QDeclarativeGeoServiceProvider *plugin
if (!plugin)
return;
- if (plugin_->ready()) {
+ if (plugin_->isAttached()) {
pluginReady();
} else {
- connect(plugin_, SIGNAL(supportedFeaturesChanged(PluginFeatures)),
+ connect(plugin_, SIGNAL(attached()),
this, SLOT(pluginReady()));
}
}
diff --git a/src/imports/location/qdeclarativegeoserviceprovider.cpp b/src/imports/location/qdeclarativegeoserviceprovider.cpp
index 13654bbe..ef2213dc 100644
--- a/src/imports/location/qdeclarativegeoserviceprovider.cpp
+++ b/src/imports/location/qdeclarativegeoserviceprovider.cpp
@@ -94,16 +94,16 @@ QT_BEGIN_NAMESPACE
QDeclarativeGeoServiceProvider::QDeclarativeGeoServiceProvider(QObject *parent)
: QObject(parent),
sharedProvider_(0),
- supported_(NoFeatures),
- required_(NoFeatures),
+ required_(new QDeclarativeGeoServiceProviderRequirements),
complete_(false),
- placesFeatures_(NoPlaceFeatures)
+ experimental_(false)
{
locales_.append(QLocale().name());
}
QDeclarativeGeoServiceProvider::~QDeclarativeGeoServiceProvider()
{
+ delete required_;
delete sharedProvider_;
}
@@ -121,68 +121,12 @@ void QDeclarativeGeoServiceProvider::setName(const QString &name)
name_ = name;
delete sharedProvider_;
- sharedProvider_ = 0;
- if (complete_)
- update();
- emit nameChanged(name_);
-}
-
-void QDeclarativeGeoServiceProvider::update(bool doEmit)
-{
- supported_ = NoFeatures;
- placesFeatures_ = NoPlaceFeatures;
-
- QGeoServiceProvider *serviceProvider = sharedGeoServiceProvider();
- if (!serviceProvider || serviceProvider->error() != QGeoServiceProvider::NoError) {
- if (doEmit) {
- emit supportedFeaturesChanged(supported_);
- emit supportedPlacesFeaturesChanged(placesFeatures_);
- }
- return;
- }
-
- if (locales_.isEmpty())
- locales_.append(QLocale().name());
-
- Q_ASSERT(!locales_.isEmpty());
- QGeocodingManager* geocodingManager = serviceProvider->geocodingManager();
- if (geocodingManager && serviceProvider->error() == QGeoServiceProvider::NoError) {
- if (geocodingManager->supportsGeocoding())
- supported_ |= GeocodingFeature;
- if (geocodingManager->supportsReverseGeocoding())
- supported_ |= ReverseGeocodingFeature;
- geocodingManager->setLocale(QLocale(locales_.at(0)));
- }
+ sharedProvider_ = new QGeoServiceProvider(name_, parameterMap());
+ sharedProvider_->setLocale(locales_.at(0));
+ sharedProvider_->setAllowExperimental(experimental_);
- QGeoRoutingManager* routingManager = serviceProvider->routingManager();
- if (routingManager && serviceProvider->error() == QGeoServiceProvider::NoError) {
- supported_ |= RoutingFeature;
- routingManager->setLocale(QLocale(locales_.at(0)));
- }
-
-
- QGeoMappingManager* mappingManager = serviceProvider->mappingManager();
- if (mappingManager && serviceProvider->error() == QGeoServiceProvider::NoError) {
- supported_ |= MappingFeature;
- mappingManager->setLocale(QLocale(locales_.at(0)));
- }
-
- QPlaceManager *placeManager = serviceProvider->placeManager();
- if (placeManager && serviceProvider->error() == QGeoServiceProvider::NoError) {
- placesFeatures_ = static_cast<QDeclarativeGeoServiceProvider::PlacesFeatures> ((int)placeManager->supportedFeatures());
- supported_ |= AnyPlacesFeature;
-
- QList<QLocale> localePreferences;
- foreach (const QString &locale, locales_)
- localePreferences.append(locale);
-
- placeManager->setLocales(localePreferences);
- }
-
- if (doEmit) {
- emit supportedFeaturesChanged(supported_);
- emit supportedPlacesFeaturesChanged(placesFeatures_);
- }
+ emit nameChanged(name_);
+ emit attached();
}
/*!
@@ -202,10 +146,15 @@ void QDeclarativeGeoServiceProvider::componentComplete()
{
complete_ = true;
if (!name_.isEmpty()) {
- update();
return;
}
- if (required_ != NoFeatures || prefer_.size() > 0) {
+
+ if (!prefer_.isEmpty()
+ || required_->mappingRequirements() != NoMappingFeatures
+ || required_->routingRequirements() != NoRoutingFeatures
+ || required_->geocodingRequirements() != NoGeocodingFeatures
+ || required_->placesRequirements() != NoPlacesFeatures) {
+
QStringList providers = QGeoServiceProvider::availableServiceProviders();
/* first check any preferred plugins */
@@ -214,18 +163,9 @@ void QDeclarativeGeoServiceProvider::componentComplete()
// so we don't try it again later
providers.removeAll(name);
- if (sharedProvider_)
- delete sharedProvider_;
- sharedProvider_ = 0;
- name_ = name;
- // do an update with no emits
- update(false);
-
- if ((supported_ & required_) == required_) {
- // run it again to send the notifications
- emit nameChanged(name_);
- emit supportedFeaturesChanged(supported_);
- emit supportedPlacesFeaturesChanged(placesFeatures_);
+ QGeoServiceProvider sp(name, parameterMap());
+ if (required_->matches(&sp)) {
+ setName(name);
return;
}
}
@@ -233,18 +173,9 @@ void QDeclarativeGeoServiceProvider::componentComplete()
/* then try the rest */
foreach (QString name, providers) {
- if (sharedProvider_)
- delete sharedProvider_;
- sharedProvider_ = 0;
- name_ = name;
- // do an update with no emits
- update(false);
-
- if ((supported_ & required_) == required_) {
- // run it again to send the notifications
- emit nameChanged(name_);
- emit supportedFeaturesChanged(supported_);
- emit supportedPlacesFeaturesChanged(placesFeatures_);
+ QGeoServiceProvider sp(name, parameterMap());
+ if (required_->matches(&sp)) {
+ setName(name);
return;
}
}
@@ -258,18 +189,48 @@ QString QDeclarativeGeoServiceProvider::name() const
return name_;
}
-/*!
- \qmlproperty enumeration Plugin::supported
+bool QDeclarativeGeoServiceProvider::supportsGeocoding(const GeocodingFeatures &feature) const
+{
+ QGeoServiceProvider *sp = sharedGeoServiceProvider();
+ QGeoServiceProvider::GeocodingFeatures f =
+ static_cast<QGeoServiceProvider::GeocodingFeature>(int(feature));
+ if (f == QGeoServiceProvider::AnyGeocodingFeatures)
+ return (sp && (sp->geocodingFeatures() != QGeoServiceProvider::NoGeocodingFeatures));
+ else
+ return (sp && (sp->geocodingFeatures() & f) == f);
+}
- This property enumerates all supported features of the currently attached
- plugin. Its value will be equal to \c{Plugin.NoFeatures} until the Plugin
- is attached.
+bool QDeclarativeGeoServiceProvider::supportsMapping(const MappingFeatures &feature) const
+{
+ QGeoServiceProvider *sp = sharedGeoServiceProvider();
+ QGeoServiceProvider::MappingFeatures f =
+ static_cast<QGeoServiceProvider::MappingFeature>(int(feature));
+ if (f == QGeoServiceProvider::AnyMappingFeatures)
+ return (sp && (sp->mappingFeatures() != QGeoServiceProvider::NoMappingFeatures));
+ else
+ return (sp && (sp->mappingFeatures() & f) == f);
+}
- See \l required for a list of possible enumeration values.
-*/
-QDeclarativeGeoServiceProvider::PluginFeatures QDeclarativeGeoServiceProvider::supportedFeatures() const
+bool QDeclarativeGeoServiceProvider::supportsRouting(const RoutingFeatures &feature) const
{
- return supported_;
+ QGeoServiceProvider *sp = sharedGeoServiceProvider();
+ QGeoServiceProvider::RoutingFeatures f =
+ static_cast<QGeoServiceProvider::RoutingFeature>(int(feature));
+ if (f == QGeoServiceProvider::AnyRoutingFeatures)
+ return (sp && (sp->routingFeatures() != QGeoServiceProvider::NoRoutingFeatures));
+ else
+ return (sp && (sp->routingFeatures() & f) == f);
+}
+
+bool QDeclarativeGeoServiceProvider::supportsPlaces(const PlacesFeatures &feature) const
+{
+ QGeoServiceProvider *sp = sharedGeoServiceProvider();
+ QGeoServiceProvider::PlacesFeatures f =
+ static_cast<QGeoServiceProvider::PlacesFeature>(int(feature));
+ if (f == QGeoServiceProvider::AnyPlacesFeatures)
+ return (sp && (sp->placesFeatures() != QGeoServiceProvider::NoPlacesFeatures));
+ else
+ return (sp && (sp->placesFeatures() & f) == f);
}
/*!
@@ -291,17 +252,11 @@ QDeclarativeGeoServiceProvider::PluginFeatures QDeclarativeGeoServiceProvider::s
\li Plugin.AnyPlacesFeature
\endlist
*/
-QDeclarativeGeoServiceProvider::PluginFeatures QDeclarativeGeoServiceProvider::requiredFeatures() const
+QDeclarativeGeoServiceProviderRequirements *QDeclarativeGeoServiceProvider::requirements() const
{
return required_;
}
-void QDeclarativeGeoServiceProvider::setRequiredFeatures(const PluginFeatures &features)
-{
- required_ = features;
- emit requiredFeaturesChanged(required_);
-}
-
/*!
\qmlproperty list<string> Plugin::preferred
@@ -320,65 +275,36 @@ void QDeclarativeGeoServiceProvider::setPreferred(const QStringList &val)
emit preferredChanged(prefer_);
}
-bool QDeclarativeGeoServiceProvider::ready() const
+/*!
+ \qmlproperty bool Plugin::isAttached
+*/
+bool QDeclarativeGeoServiceProvider::isAttached() const
{
- return complete_;
+ return (sharedProvider_ != 0);
}
/*!
- \qmlproperty enumeration Plugin::supportedPlacesFeatures
-
- This property holds a set of flags indicating what Places related features are provided by the
- plugin. It can be a binary concatenation of the following values:
-
- \table
- \row
- \li Plugin.NoFeatures
- \li No features specified/supported (value: 0x0).
- \row
- \li Plugin.SavePlaceFeature
- \li The plugin can be used to save places (value: 0x1).
- \row
- \li Plugin.RemovePlaceFeature
- \li The plugin can be used to remove places (value: 0x2).
- \row
- \li Plugin.SaveCategoryFeature
- \li The plugin can be used to save categories (value: 0x4).
- \row
- \li Plugin.RemoveCategoryFeature
- \li The plugin can be used to remove categories (value: 0x8).
- \row
- \li Plugin.RecommendationsFeature
- \li The plugin can provide recommendations (value: 0x10).
- \row
- \li Plugin.SearchSuggestionsFeature\
- \li The plugin can be used to provide search term suggestions (value: 0x20).
- \row
- \li Plugin.CorrectionsFeature
- \li The plugin can provide search term corrections (value: 0x40).
- \row
- \li Plugin.LocaleFeature
- \li The plugin can provide place data information localized according to a set of preferred locales (value: 0x80).
- \row
- \li Plugin.NotificationsFeature
- \li The plugin has notification mechanisms for when places/categories are added/modified/removed (value: 0x100).
- \row
- \li Plugin.FavoritesMatchingFeature
- \li The plugin has a mechanism to match places against places from other plugins (value: 0x200).
- \endtable
+ \qmlproperty bool Plugin::allowExperimental
*/
-QDeclarativeGeoServiceProvider::PlacesFeatures QDeclarativeGeoServiceProvider::supportedPlacesFeatures() const
+bool QDeclarativeGeoServiceProvider::allowExperimental() const
{
- if ((supported_ & AnyPlacesFeature) == 0)
- return QDeclarativeGeoServiceProvider::NoPlaceFeatures;
- return placesFeatures_;
+ return experimental_;
}
-QGeoServiceProvider *QDeclarativeGeoServiceProvider::sharedGeoServiceProvider()
+void QDeclarativeGeoServiceProvider::setAllowExperimental(bool allow)
{
- if (!sharedProvider_)
- sharedProvider_ = new QGeoServiceProvider(name(), parameterMap());
+ if (experimental_ == allow)
+ return;
+
+ experimental_ = allow;
+ if (sharedProvider_)
+ sharedProvider_->setAllowExperimental(allow);
+ emit allowExperimentalChanged(allow);
+}
+
+QGeoServiceProvider *QDeclarativeGeoServiceProvider::sharedGeoServiceProvider() const
+{
return sharedProvider_;
}
@@ -416,8 +342,8 @@ void QDeclarativeGeoServiceProvider::setLocales(const QStringList &locales)
if (locales_.isEmpty())
locales_.append(QLocale().name());
- if (complete_)
- update();
+ if (sharedProvider_)
+ sharedProvider_->setLocale(locales_.at(0));
emit localesChanged();
}
@@ -440,9 +366,10 @@ QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> QDeclarativeGe
void QDeclarativeGeoServiceProvider::parameter_append(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop, QDeclarativeGeoServiceProviderParameter *parameter)
{
- static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->parameters_.append(parameter);
- delete static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->sharedProvider_;
- static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->sharedProvider_ = 0;
+ QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider*>(prop->object);
+ p->parameters_.append(parameter);
+ if (p->sharedProvider_)
+ p->sharedProvider_->setParameters(p->parameterMap());
}
int QDeclarativeGeoServiceProvider::parameter_count(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop)
@@ -457,9 +384,10 @@ QDeclarativeGeoServiceProviderParameter* QDeclarativeGeoServiceProvider::paramet
void QDeclarativeGeoServiceProvider::parameter_clear(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop)
{
- static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->parameters_.clear();
- delete static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->sharedProvider_;
- static_cast<QDeclarativeGeoServiceProvider*>(prop->object)->sharedProvider_ = 0;
+ QDeclarativeGeoServiceProvider *p = static_cast<QDeclarativeGeoServiceProvider*>(prop->object);
+ p->parameters_.clear();
+ if (p->sharedProvider_)
+ p->sharedProvider_->setParameters(p->parameterMap());
}
QMap<QString, QVariant> QDeclarativeGeoServiceProvider::parameterMap() const
@@ -473,6 +401,134 @@ QMap<QString, QVariant> QDeclarativeGeoServiceProvider::parameterMap() const
return map;
}
+
+/*******************************************************************************
+*******************************************************************************/
+
+QDeclarativeGeoServiceProviderRequirements::QDeclarativeGeoServiceProviderRequirements(QObject *parent)
+ : QObject(parent),
+ mapping_(QDeclarativeGeoServiceProvider::NoMappingFeatures),
+ routing_(QDeclarativeGeoServiceProvider::NoRoutingFeatures),
+ geocoding_(QDeclarativeGeoServiceProvider::NoGeocodingFeatures),
+ places_(QDeclarativeGeoServiceProvider::NoPlacesFeatures)
+{
+}
+
+QDeclarativeGeoServiceProviderRequirements::~QDeclarativeGeoServiceProviderRequirements()
+{
+}
+
+QDeclarativeGeoServiceProvider::MappingFeatures QDeclarativeGeoServiceProviderRequirements::mappingRequirements() const
+{
+ return mapping_;
+}
+
+void QDeclarativeGeoServiceProviderRequirements::setMappingRequirements(const QDeclarativeGeoServiceProvider::MappingFeatures &features)
+{
+ if (mapping_ == features)
+ return;
+
+ mapping_ = features;
+ emit mappingRequirementsChanged(mapping_);
+ emit requirementsChanged();
+}
+
+QDeclarativeGeoServiceProvider::RoutingFeatures QDeclarativeGeoServiceProviderRequirements::routingRequirements() const
+{
+ return routing_;
+}
+
+void QDeclarativeGeoServiceProviderRequirements::setRoutingRequirements(const QDeclarativeGeoServiceProvider::RoutingFeatures &features)
+{
+ if (routing_ == features)
+ return;
+
+ routing_ = features;
+ emit routingRequirementsChanged(routing_);
+ emit requirementsChanged();
+}
+
+QDeclarativeGeoServiceProvider::GeocodingFeatures QDeclarativeGeoServiceProviderRequirements::geocodingRequirements() const
+{
+ return geocoding_;
+}
+
+void QDeclarativeGeoServiceProviderRequirements::setGeocodingRequirements(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features)
+{
+ if (geocoding_ == features)
+ return;
+
+ geocoding_ = features;
+ emit geocodingRequirementsChanged(geocoding_);
+ emit requirementsChanged();
+}
+
+QDeclarativeGeoServiceProvider::PlacesFeatures QDeclarativeGeoServiceProviderRequirements::placesRequirements() const
+{
+ return places_;
+}
+
+void QDeclarativeGeoServiceProviderRequirements::setPlacesRequirements(const QDeclarativeGeoServiceProvider::PlacesFeatures &features)
+{
+ if (places_ == features)
+ return;
+
+ places_ = features;
+ emit placesRequirementsChanged(places_);
+ emit requirementsChanged();
+}
+
+bool QDeclarativeGeoServiceProviderRequirements::matches(const QGeoServiceProvider *provider) const
+{
+ QGeoServiceProvider::MappingFeatures mapping =
+ static_cast<QGeoServiceProvider::MappingFeatures>(int(mapping_));
+
+ // extra curlies here to avoid "dangling" else, which could belong to either if
+ // same goes for all the rest of these blocks
+ if (mapping == QGeoServiceProvider::AnyMappingFeatures) {
+ if (provider->mappingFeatures() == QGeoServiceProvider::NoMappingFeatures)
+ return false;
+ } else {
+ if ((provider->mappingFeatures() & mapping) != mapping)
+ return false;
+ }
+
+ QGeoServiceProvider::RoutingFeatures routing =
+ static_cast<QGeoServiceProvider::RoutingFeatures>(int(routing_));
+
+ if (routing == QGeoServiceProvider::AnyRoutingFeatures) {
+ if (provider->routingFeatures() == QGeoServiceProvider::NoRoutingFeatures)
+ return false;
+ } else {
+ if ((provider->routingFeatures() & routing) != routing)
+ return false;
+ }
+
+ QGeoServiceProvider::GeocodingFeatures geocoding =
+ static_cast<QGeoServiceProvider::GeocodingFeatures>(int(geocoding_));
+
+ if (geocoding == QGeoServiceProvider::AnyGeocodingFeatures) {
+ if (provider->geocodingFeatures() == QGeoServiceProvider::NoGeocodingFeatures)
+ return false;
+ } else {
+ if ((provider->geocodingFeatures() & geocoding) != geocoding)
+ return false;
+ }
+
+ QGeoServiceProvider::PlacesFeatures places =
+ static_cast<QGeoServiceProvider::PlacesFeatures>(int(places_));
+
+ if (places == QGeoServiceProvider::AnyPlacesFeatures) {
+ if (provider->placesFeatures() == QGeoServiceProvider::NoPlacesFeatures)
+ return false;
+ } else {
+ if ((provider->placesFeatures() & places) != places)
+ return false;
+ }
+
+ return true;
+}
+
/*******************************************************************************
*******************************************************************************/
diff --git a/src/imports/location/qdeclarativegeoserviceprovider_p.h b/src/imports/location/qdeclarativegeoserviceprovider_p.h
index 34cad124..dbf39626 100644
--- a/src/imports/location/qdeclarativegeoserviceprovider_p.h
+++ b/src/imports/location/qdeclarativegeoserviceprovider_p.h
@@ -45,6 +45,7 @@
#include <qgeocoordinate.h>
#include <QtQuick/QQuickItem>
#include <QtDeclarative/QDeclarativeParserStatus>
+#include <QtLocation/QGeoServiceProvider>
#include <QtLocation/QPlaceManager>
#include <QMap>
@@ -53,8 +54,6 @@
QT_BEGIN_NAMESPACE
-class QGeoServiceProvider;
-
class QDeclarativeGeoServiceProviderParameter : public QObject
{
Q_OBJECT
@@ -81,20 +80,24 @@ private:
QVariant value_;
};
+class QDeclarativeGeoServiceProviderRequirements;
+
class QDeclarativeGeoServiceProvider : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
- Q_ENUMS (PlacesFeature)
- Q_ENUMS (PluginFeature)
+ Q_ENUMS(RoutingFeature)
+ Q_ENUMS(GeocodingFeature)
+ Q_ENUMS(MappingFeature)
+ Q_ENUMS(PlacesFeature)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QStringList availableServiceProviders READ availableServiceProviders CONSTANT)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> parameters READ parameters)
- Q_PROPERTY(PluginFeatures required READ requiredFeatures WRITE setRequiredFeatures NOTIFY requiredFeaturesChanged)
- Q_PROPERTY(PluginFeatures supported READ supportedFeatures NOTIFY supportedFeaturesChanged)
- Q_PROPERTY(PlacesFeatures supportedPlacesFeatures READ supportedPlacesFeatures NOTIFY supportedPlacesFeaturesChanged)
+ Q_PROPERTY(QDeclarativeGeoServiceProviderRequirements *required READ requirements)
Q_PROPERTY(QStringList locales READ locales WRITE setLocales NOTIFY localesChanged)
Q_PROPERTY(QStringList preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
+ Q_PROPERTY(bool allowExperimental READ allowExperimental WRITE setAllowExperimental NOTIFY allowExperimentalChanged)
+ Q_PROPERTY(bool isAttached READ isAttached NOTIFY attached)
Q_CLASSINFO("DefaultProperty", "parameters")
Q_INTERFACES(QDeclarativeParserStatus)
@@ -103,32 +106,60 @@ public:
QDeclarativeGeoServiceProvider(QObject *parent = 0);
~QDeclarativeGeoServiceProvider();
- enum PluginFeature {
- NoFeatures = 0x00000000,
- GeocodingFeature = 0x00000001,
- ReverseGeocodingFeature = 0x00000002,
- RoutingFeature = 0x00000004,
- MappingFeature = 0x00000008,
- AnyPlacesFeature = 0x00000010
+ enum RoutingFeature {
+ NoRoutingFeatures = QGeoServiceProvider::NoRoutingFeatures,
+ OnlineRoutingFeature = QGeoServiceProvider::OnlineRoutingFeature,
+ OfflineRoutingFeature = QGeoServiceProvider::OfflineRoutingFeature,
+ LocalizedRoutingFeature = QGeoServiceProvider::LocalizedRoutingFeature,
+ RouteUpdatesFeature = QGeoServiceProvider::RouteUpdatesFeature,
+ AlternativeRoutesFeature = QGeoServiceProvider::AlternativeRoutesFeature,
+ ExcludeAreasRoutingFeature = QGeoServiceProvider::ExcludeAreasRoutingFeature,
+ AnyRoutingFeatures = QGeoServiceProvider::AnyRoutingFeatures
};
- Q_DECLARE_FLAGS(PluginFeatures, PluginFeature)
- Q_FLAGS(PluginFeatures)
+ enum GeocodingFeature {
+ NoGeocodingFeatures = QGeoServiceProvider::NoGeocodingFeatures,
+ OnlineGeocodingFeature = QGeoServiceProvider::OnlineGeocodingFeature,
+ OfflineGeocodingFeature = QGeoServiceProvider::OfflineGeocodingFeature,
+ ReverseGeocodingFeature = QGeoServiceProvider::ReverseGeocodingFeature,
+ LocalizedGeocodingFeature = QGeoServiceProvider::LocalizedGeocodingFeature,
+ AnyGeocodingFeatures = QGeoServiceProvider::AnyGeocodingFeatures
+ };
+
+ enum MappingFeature {
+ NoMappingFeatures = QGeoServiceProvider::NoMappingFeatures,
+ OnlineMappingFeature = QGeoServiceProvider::OnlineMappingFeature,
+ OfflineMappingFeature = QGeoServiceProvider::OfflineMappingFeature,
+ LocalizedMappingFeature = QGeoServiceProvider::LocalizedMappingFeature,
+ AnyMappingFeatures = QGeoServiceProvider::AnyMappingFeatures
+ };
enum PlacesFeature {
- NoPlaceFeatures = QPlaceManager::NoFeatures,
- SavePlaceFeature = QPlaceManager::SavePlaceFeature,
- RemovePlaceFeature = QPlaceManager::RemovePlaceFeature,
- SaveCategoryFeature = QPlaceManager:: SaveCategoryFeature,
- RemoveCategoryFeature = QPlaceManager::RemoveCategoryFeature,
- RecommendationsFeature = QPlaceManager::RecommendationsFeature,
- SearchSuggestionsFeature = QPlaceManager::SearchSuggestionsFeature,
- CorrectionsFeature = QPlaceManager::CorrectionsFeature,
- LocaleFeature = QPlaceManager::LocaleFeature,
- NotificationsFeature = QPlaceManager::NotificationsFeature,
- FavoritesMatchingFeature = QPlaceManager::MatchingFeature
+ NoPlacesFeatures = QGeoServiceProvider::NoPlacesFeatures,
+ OnlinePlacesFeature = QGeoServiceProvider::OnlinePlacesFeature,
+ OfflinePlacesFeature = QGeoServiceProvider::OfflinePlacesFeature,
+ SavePlaceFeature = QGeoServiceProvider::SavePlaceFeature,
+ RemovePlaceFeature = QGeoServiceProvider::RemovePlaceFeature,
+ SaveCategoryFeature = QGeoServiceProvider::SaveCategoryFeature,
+ RemoveCategoryFeature = QGeoServiceProvider::RemoveCategoryFeature,
+ PlaceRecommendationsFeature = QGeoServiceProvider::PlaceRecommendationsFeature,
+ SearchSuggestionsFeature = QGeoServiceProvider::SearchSuggestionsFeature,
+ CorrectionsFeature = QGeoServiceProvider::CorrectionsFeature,
+ LocalizedPlacesFeature = QGeoServiceProvider::LocalizedPlacesFeature,
+ NotificationsFeature = QGeoServiceProvider::NotificationsFeature,
+ PlaceMatchingFeature = QGeoServiceProvider::PlaceMatchingFeature,
+ AnyPlacesFeatures = QGeoServiceProvider::AnyPlacesFeatures
};
+ Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)
+ Q_FLAGS(RoutingFeatures)
+
+ Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)
+ Q_FLAGS(GeocodingFeatures)
+
+ Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)
+ Q_FLAGS(MappingFeatures)
+
Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)
Q_FLAGS(PlacesFeatures)
@@ -144,55 +175,104 @@ public:
QStringList availableServiceProviders();
- PluginFeatures supportedFeatures() const;
-
- PluginFeatures requiredFeatures() const;
- void setRequiredFeatures(const PluginFeatures &features);
-
- PlacesFeatures supportedPlacesFeatures() const;
+ QDeclarativeGeoServiceProviderRequirements *requirements() const;
QStringList preferred() const;
void setPreferred(const QStringList &val);
- QGeoServiceProvider *sharedGeoServiceProvider();
+ QGeoServiceProvider *sharedGeoServiceProvider() const;
+
+ Q_INVOKABLE bool supportsRouting(const RoutingFeatures &feature = AnyRoutingFeatures) const;
+ Q_INVOKABLE bool supportsGeocoding(const GeocodingFeatures &feature = AnyGeocodingFeatures) const;
+ Q_INVOKABLE bool supportsMapping(const MappingFeatures &feature = AnyMappingFeatures) const;
+ Q_INVOKABLE bool supportsPlaces(const PlacesFeatures &feature = AnyPlacesFeatures) const;
QStringList locales() const;
void setLocales(const QStringList &locales);
- bool ready() const;
+ bool isAttached() const;
+
+ void setAllowExperimental(bool allow);
+ bool allowExperimental() const;
Q_SIGNALS:
void nameChanged(const QString &name);
void localesChanged();
- void supportedFeaturesChanged(const PluginFeatures &features);
- void requiredFeaturesChanged(const PluginFeatures &features);
- void supportedPlacesFeaturesChanged(const PlacesFeatures &features);
+ void attached();
void preferredChanged(const QStringList &preferences);
+ void allowExperimentalChanged(bool allow);
private:
static void parameter_append(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop, QDeclarativeGeoServiceProviderParameter *mapObject);
static int parameter_count(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop);
static QDeclarativeGeoServiceProviderParameter* parameter_at(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop, int index);
static void parameter_clear(QDeclarativeListProperty<QDeclarativeGeoServiceProviderParameter> *prop);
- void update(bool doEmit = true);
QGeoServiceProvider *sharedProvider_;
QString name_;
QList<QDeclarativeGeoServiceProviderParameter*> parameters_;
- PluginFeatures supported_;
- PluginFeatures required_;
+ QDeclarativeGeoServiceProviderRequirements *required_;
bool complete_;
+ bool experimental_;
QStringList locales_;
QStringList prefer_;
- PlacesFeatures placesFeatures_;
Q_DISABLE_COPY(QDeclarativeGeoServiceProvider)
};
+class QDeclarativeGeoServiceProviderRequirements : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QDeclarativeGeoServiceProvider::MappingFeatures mapping
+ READ mappingRequirements WRITE setMappingRequirements
+ NOTIFY mappingRequirementsChanged)
+ Q_PROPERTY(QDeclarativeGeoServiceProvider::RoutingFeatures routing
+ READ routingRequirements WRITE setRoutingRequirements
+ NOTIFY routingRequirementsChanged)
+ Q_PROPERTY(QDeclarativeGeoServiceProvider::GeocodingFeatures geocoding
+ READ geocodingRequirements WRITE setGeocodingRequirements
+ NOTIFY geocodingRequirementsChanged)
+ Q_PROPERTY(QDeclarativeGeoServiceProvider::PlacesFeatures places
+ READ placesRequirements WRITE setPlacesRequirements
+ NOTIFY placesRequirementsChanged)
+
+public:
+ QDeclarativeGeoServiceProviderRequirements(QObject *parent = 0);
+ ~QDeclarativeGeoServiceProviderRequirements();
+
+ QDeclarativeGeoServiceProvider::MappingFeatures mappingRequirements() const;
+ void setMappingRequirements(const QDeclarativeGeoServiceProvider::MappingFeatures &features);
+
+ QDeclarativeGeoServiceProvider::RoutingFeatures routingRequirements() const;
+ void setRoutingRequirements(const QDeclarativeGeoServiceProvider::RoutingFeatures &features);
+
+ QDeclarativeGeoServiceProvider::GeocodingFeatures geocodingRequirements() const;
+ void setGeocodingRequirements(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features);
+
+ QDeclarativeGeoServiceProvider::PlacesFeatures placesRequirements() const;
+ void setPlacesRequirements(const QDeclarativeGeoServiceProvider::PlacesFeatures &features);
+
+ Q_INVOKABLE bool matches(const QGeoServiceProvider *provider) const;
+
+signals:
+ void mappingRequirementsChanged(const QDeclarativeGeoServiceProvider::MappingFeatures &features);
+ void routingRequirementsChanged(const QDeclarativeGeoServiceProvider::RoutingFeatures &features);
+ void geocodingRequirementsChanged(const QDeclarativeGeoServiceProvider::GeocodingFeatures &features);
+ void placesRequirementsChanged(const QDeclarativeGeoServiceProvider::PlacesFeatures &features);
+
+ void requirementsChanged();
+
+private:
+ QDeclarativeGeoServiceProvider::MappingFeatures mapping_;
+ QDeclarativeGeoServiceProvider::RoutingFeatures routing_;
+ QDeclarativeGeoServiceProvider::GeocodingFeatures geocoding_;
+ QDeclarativeGeoServiceProvider::PlacesFeatures places_;
+
+};
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeGeoServiceProviderParameter));
+QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeGeoServiceProviderRequirements));
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeGeoServiceProvider));
-Q_DECLARE_OPERATORS_FOR_FLAGS(QT_PREPEND_NAMESPACE(QDeclarativeGeoServiceProvider::PlacesFeatures))
-Q_DECLARE_OPERATORS_FOR_FLAGS(QT_PREPEND_NAMESPACE(QDeclarativeGeoServiceProvider::PluginFeatures))
#endif
diff --git a/src/location/maps/qgeocodingmanager.cpp b/src/location/maps/qgeocodingmanager.cpp
index bb44c98e..cb4bc3f7 100644
--- a/src/location/maps/qgeocodingmanager.cpp
+++ b/src/location/maps/qgeocodingmanager.cpp
@@ -271,25 +271,6 @@ QGeocodeReply* QGeocodingManager::geocode(const QString &address,
}
/*!
- Returns whether this manager supports geocoding.
-*/
-bool QGeocodingManager::supportsGeocoding() const
-{
-// if (!d_ptr->engine)
-// return false;
-
- return d_ptr->engine->supportsGeocoding();
-}
-
-/*!
- Returns whether this manager supports reverse geocoding.
-*/
-bool QGeocodingManager::supportsReverseGeocoding() const
-{
- return d_ptr->engine->supportsReverseGeocoding();
-}
-
-/*!
Sets the locale to be used by this manager to \a locale.
If this geocoding manager supports returning the results
diff --git a/src/location/maps/qgeocodingmanager.h b/src/location/maps/qgeocodingmanager.h
index da85132d..b3a9c339 100644
--- a/src/location/maps/qgeocodingmanager.h
+++ b/src/location/maps/qgeocodingmanager.h
@@ -79,9 +79,6 @@ public:
QGeocodeReply* reverseGeocode(const QGeoCoordinate &coordinate,
const QGeoBoundingArea &bounds = QGeoBoundingArea());
- bool supportsGeocoding() const;
- bool supportsReverseGeocoding() const;
-
void setLocale(const QLocale &locale);
QLocale locale() const;
diff --git a/src/location/maps/qgeocodingmanagerengine.cpp b/src/location/maps/qgeocodingmanagerengine.cpp
index 5d9412e2..b4478e29 100644
--- a/src/location/maps/qgeocodingmanagerengine.cpp
+++ b/src/location/maps/qgeocodingmanagerengine.cpp
@@ -272,46 +272,6 @@ QGeocodeReply* QGeocodingManagerEngine::geocode(const QString &address,
}
/*!
- Sets whether geocoding is supported by this engine to \a supported.
-
- It is important that subclasses use this method to ensure that the engine
- reports its capabilities correctly. If this function is not used the
- engine will report that it does not support geocoding.
-*/
-void QGeocodingManagerEngine::setSupportsGeocoding(bool supported)
-{
- d_ptr->supportsGeocoding = supported;
-}
-
-/*!
- Returns whether this engine supports geocoding.
-*/
-bool QGeocodingManagerEngine::supportsGeocoding() const
-{
- return d_ptr->supportsGeocoding;
-}
-
-/*!
- Sets whether reverse geocoding is supported by this engine to \a supported.
-
- It is important that subclasses use this method to ensure that the engine
- reports its capabilities correctly. If this function is not used the
- engine will report that it does not support reverse geocoding.
-*/
-void QGeocodingManagerEngine::setSupportsReverseGeocoding(bool supported)
-{
- d_ptr->supportsReverseGeocoding = supported;
-}
-
-/*!
- Returns whether this engine supports reverse geocoding.
-*/
-bool QGeocodingManagerEngine::supportsReverseGeocoding() const
-{
- return d_ptr->supportsReverseGeocoding;
-}
-
-/*!
Sets the locale to be used by this manager to \a locale.
If this geocoding manager supports returning the results
@@ -367,9 +327,8 @@ QLocale QGeocodingManagerEngine::locale() const
*******************************************************************************/
QGeocodingManagerEnginePrivate::QGeocodingManagerEnginePrivate()
- : managerVersion(-1),
- supportsGeocoding(false),
- supportsReverseGeocoding(false) {}
+ : managerVersion(-1)
+{}
QGeocodingManagerEnginePrivate::~QGeocodingManagerEnginePrivate()
{
diff --git a/src/location/maps/qgeocodingmanagerengine.h b/src/location/maps/qgeocodingmanagerengine.h
index 49069dd5..d4a4451f 100644
--- a/src/location/maps/qgeocodingmanagerengine.h
+++ b/src/location/maps/qgeocodingmanagerengine.h
@@ -77,10 +77,6 @@ public:
const QGeoBoundingArea &bounds);
-
- bool supportsGeocoding() const;
- bool supportsReverseGeocoding() const;
-
void setLocale(const QLocale &locale);
QLocale locale() const;
@@ -88,10 +84,6 @@ Q_SIGNALS:
void finished(QGeocodeReply* reply);
void error(QGeocodeReply* reply, QGeocodeReply::Error error, QString errorString = QString());
-protected:
- void setSupportsGeocoding(bool supported);
- void setSupportsReverseGeocoding(bool supported);
-
private:
void setManagerName(const QString &managerName);
void setManagerVersion(int managerVersion);
diff --git a/src/location/maps/qgeocodingmanagerengine_p.h b/src/location/maps/qgeocodingmanagerengine_p.h
index 647f9cd9..ec531365 100644
--- a/src/location/maps/qgeocodingmanagerengine_p.h
+++ b/src/location/maps/qgeocodingmanagerengine_p.h
@@ -69,9 +69,6 @@ public:
QString managerName;
int managerVersion;
- bool supportsGeocoding;
- bool supportsReverseGeocoding;
-
QLocale locale;
private:
diff --git a/src/location/maps/qgeoroutingmanager.cpp b/src/location/maps/qgeoroutingmanager.cpp
index ebd4712b..6d5e5acc 100644
--- a/src/location/maps/qgeoroutingmanager.cpp
+++ b/src/location/maps/qgeoroutingmanager.cpp
@@ -273,30 +273,6 @@ QGeoRouteReply* QGeoRoutingManager::updateRoute(const QGeoRoute &route, const QG
}
/*!
- Returns whether this manager supports updating routes.
-*/
-bool QGeoRoutingManager::supportsRouteUpdates() const
-{
- return d_ptr->engine->supportsRouteUpdates();
-}
-
-/*!
- Returns whether this manager supports request for alternative routes.
-*/
-bool QGeoRoutingManager::supportsAlternativeRoutes() const
-{
- return d_ptr->engine->supportsAlternativeRoutes();
-}
-
-/*!
- Returns whether this engine supports the exclusion of areas from routes.
-*/
-bool QGeoRoutingManager::supportsExcludeAreas() const
-{
- return d_ptr->engine->supportsExcludeAreas();
-}
-
-/*!
Returns the travel modes supported by this manager.
*/
QGeoRouteRequest::TravelModes QGeoRoutingManager::supportedTravelModes() const
diff --git a/src/location/maps/qgeoroutingmanager.h b/src/location/maps/qgeoroutingmanager.h
index dd882cac..c9131ac4 100644
--- a/src/location/maps/qgeoroutingmanager.h
+++ b/src/location/maps/qgeoroutingmanager.h
@@ -71,9 +71,6 @@ public:
QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request);
QGeoRouteReply* updateRoute(const QGeoRoute &route, const QGeoCoordinate &position);
- bool supportsRouteUpdates() const;
- bool supportsAlternativeRoutes() const;
- bool supportsExcludeAreas() const;
QGeoRouteRequest::TravelModes supportedTravelModes() const;
QGeoRouteRequest::FeatureTypes supportedFeatureTypes() const;
QGeoRouteRequest::FeatureWeights supportedFeatureWeights() const;
diff --git a/src/location/maps/qgeoroutingmanagerengine.cpp b/src/location/maps/qgeoroutingmanagerengine.cpp
index bc6ae5f7..d6f64e2c 100644
--- a/src/location/maps/qgeoroutingmanagerengine.cpp
+++ b/src/location/maps/qgeoroutingmanagerengine.cpp
@@ -208,66 +208,6 @@ QGeoRouteReply* QGeoRoutingManagerEngine::updateRoute(const QGeoRoute &route, co
}
/*!
- Sets whether this engine supports updating routes to \a supported.
-
- It is important that subclasses use this method to ensure that the engine
- reports its capabilities correctly. If this function is not used the
- engine will report that it does not support updating routes.
-*/
-void QGeoRoutingManagerEngine::setSupportsRouteUpdates(bool supported)
-{
- d_ptr->supportsRouteUpdates = supported;
-}
-
-/*!
- Returns whether this engine supports updating routes.
-*/
-bool QGeoRoutingManagerEngine::supportsRouteUpdates() const
-{
- return d_ptr->supportsRouteUpdates;
-}
-
-/*!
- Sets whether this engine supports request for alternative routes to \a supported.
-
- It is important that subclasses use this method to ensure that the engine
- reports its capabilities correctly. If this function is not used the
- engine will report that it does not support alternative routes.
-*/
-void QGeoRoutingManagerEngine::setSupportsAlternativeRoutes(bool supported)
-{
- d_ptr->supportsAlternativeRoutes = supported;
-}
-
-/*!
- Returns whether this engine supports request for alternative routes.
-*/
-bool QGeoRoutingManagerEngine::supportsAlternativeRoutes() const
-{
- return d_ptr->supportsAlternativeRoutes;
-}
-
-/*!
- Sets whether this engine supports request for excluding areas from routes to \a supported.
-
- It is important that subclasses use this method to ensure that the engine
- reports its capabilities correctly. If this function is not used the
- engine will report that it does not support excluding areas.
-*/
-void QGeoRoutingManagerEngine::setSupportsExcludeAreas(bool supported)
-{
- d_ptr->supportsExcludeAreas = supported;
-}
-
-/*!
- Returns whether this engine supports the exclusion of areas from routes.
-*/
-bool QGeoRoutingManagerEngine::supportsExcludeAreas() const
-{
- return d_ptr->supportsExcludeAreas;
-}
-
-/*!
Sets the travel modes supported by this engine to \a travelModes.
It is important that subclasses use this method to ensure that the engine
@@ -451,10 +391,7 @@ Use deleteLater() instead.
*******************************************************************************/
QGeoRoutingManagerEnginePrivate::QGeoRoutingManagerEnginePrivate()
- : managerVersion(-1),
- supportsRouteUpdates(false),
- supportsAlternativeRoutes(false),
- supportsExcludeAreas(false)
+ : managerVersion(-1)
{
}
diff --git a/src/location/maps/qgeoroutingmanagerengine.h b/src/location/maps/qgeoroutingmanagerengine.h
index c943a82b..3ddf863f 100644
--- a/src/location/maps/qgeoroutingmanagerengine.h
+++ b/src/location/maps/qgeoroutingmanagerengine.h
@@ -71,9 +71,6 @@ public:
virtual QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request) = 0;
virtual QGeoRouteReply* updateRoute(const QGeoRoute &route, const QGeoCoordinate &position);
- bool supportsRouteUpdates() const;
- bool supportsAlternativeRoutes() const;
- bool supportsExcludeAreas() const;
QGeoRouteRequest::TravelModes supportedTravelModes() const;
QGeoRouteRequest::FeatureTypes supportedFeatureTypes() const;
QGeoRouteRequest::FeatureWeights supportedFeatureWeights() const;
@@ -89,9 +86,6 @@ Q_SIGNALS:
void error(QGeoRouteReply* reply, QGeoRouteReply::Error error, QString errorString = QString());
protected:
- void setSupportsRouteUpdates(bool supported);
- void setSupportsAlternativeRoutes(bool supported);
- void setSupportsExcludeAreas(bool supported);
void setSupportedTravelModes(QGeoRouteRequest::TravelModes travelModes);
void setSupportedFeatureTypes(QGeoRouteRequest::FeatureTypes featureTypes);
void setSupportedFeatureWeights(QGeoRouteRequest::FeatureWeights featureWeights);
diff --git a/src/location/maps/qgeoroutingmanagerengine_p.h b/src/location/maps/qgeoroutingmanagerengine_p.h
index d4dda277..c114589e 100644
--- a/src/location/maps/qgeoroutingmanagerengine_p.h
+++ b/src/location/maps/qgeoroutingmanagerengine_p.h
@@ -69,9 +69,6 @@ public:
QString managerName;
int managerVersion;
- bool supportsRouteUpdates;
- bool supportsAlternativeRoutes;
- bool supportsExcludeAreas;
QGeoRouteRequest::TravelModes supportedTravelModes;
QGeoRouteRequest::FeatureTypes supportedFeatureTypes;
QGeoRouteRequest::FeatureWeights supportedFeatureWeights;
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp
index 55678b2c..aad4138d 100644
--- a/src/location/maps/qgeoserviceprovider.cpp
+++ b/src/location/maps/qgeoserviceprovider.cpp
@@ -62,15 +62,19 @@
#include <QStringList>
#include <QCoreApplication>
#include <QObject>
+#include <QMetaObject>
+#include <QMetaEnum>
#include <QProcess>
#include <QEventLoop>
+#include <QString>
#include <QtCore/private/qfactoryloader_p.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QT_GEOSERVICE_BACKEND_INTERFACE, QLatin1String("/geoservices")))
+ ("org.qt-project.qt.geoservice.serviceproviderfactory/5.0",
+ QLatin1String("/geoservices")))
#endif
/*!
@@ -144,11 +148,13 @@ QStringList QGeoServiceProvider::availableServiceProviders()
If no plugin matching \a providerName was able to be loaded then error()
and errorString() will provide details about why this is the case.
*/
-QGeoServiceProvider::QGeoServiceProvider(const QString &providerName, const QMap<QString, QVariant> &parameters)
+QGeoServiceProvider::QGeoServiceProvider(const QString &providerName, const QMap<QString, QVariant> &parameters, bool experimental)
: d_ptr(new QGeoServiceProviderPrivate())
{
- d_ptr->loadPlugin(providerName, parameters);
+ d_ptr->experimental = experimental;
d_ptr->parameterMap = parameters;
+ d_ptr->providerName = providerName;
+ d_ptr->loadMeta();
}
/*!
@@ -159,6 +165,90 @@ QGeoServiceProvider::~QGeoServiceProvider()
delete d_ptr;
}
+QGeoServiceProvider::RoutingFeatures QGeoServiceProvider::routingFeatures() const
+{
+ const QMetaObject *mo = QGeoServiceProvider::metaObject();
+ const QMetaEnum en = mo->enumerator(
+ mo->indexOfEnumerator("RoutingFeatures"));
+
+ RoutingFeatures ret = NoRoutingFeatures;
+ if (d_ptr->metaData.contains(QStringLiteral("Features"))
+ && d_ptr->metaData.value(QStringLiteral("Features")).isArray()) {
+ QJsonArray features = d_ptr->metaData.value(QStringLiteral("Features")).toArray();
+ foreach (QJsonValue v, features) {
+ int val = en.keyToValue(v.toString().toAscii().constData());
+ if (v.isString() && val != -1) {
+ ret |= RoutingFeature(val);
+ }
+ }
+ }
+
+ return ret;
+}
+
+QGeoServiceProvider::GeocodingFeatures QGeoServiceProvider::geocodingFeatures() const
+{
+ const QMetaObject *mo = QGeoServiceProvider::metaObject();
+ const QMetaEnum en = mo->enumerator(
+ mo->indexOfEnumerator("GeocodingFeatures"));
+
+ GeocodingFeatures ret = NoGeocodingFeatures;
+ if (d_ptr->metaData.contains(QStringLiteral("Features"))
+ && d_ptr->metaData.value(QStringLiteral("Features")).isArray()) {
+ QJsonArray features = d_ptr->metaData.value(QStringLiteral("Features")).toArray();
+ foreach (QJsonValue v, features) {
+ int val = en.keyToValue(v.toString().toAscii().constData());
+ if (v.isString() && val != -1) {
+ ret |= GeocodingFeature(val);
+ }
+ }
+ }
+
+ return ret;
+}
+
+QGeoServiceProvider::MappingFeatures QGeoServiceProvider::mappingFeatures() const
+{
+ const QMetaObject *mo = QGeoServiceProvider::metaObject();
+ const QMetaEnum en = mo->enumerator(
+ mo->indexOfEnumerator("MappingFeatures"));
+
+ MappingFeatures ret = NoMappingFeatures;
+ if (d_ptr->metaData.contains(QStringLiteral("Features"))
+ && d_ptr->metaData.value(QStringLiteral("Features")).isArray()) {
+ QJsonArray features = d_ptr->metaData.value(QStringLiteral("Features")).toArray();
+ foreach (QJsonValue v, features) {
+ int val = en.keyToValue(v.toString().toAscii().constData());
+ if (v.isString() && val != -1) {
+ ret |= MappingFeature(val);
+ }
+ }
+ }
+
+ return ret;
+}
+
+QGeoServiceProvider::PlacesFeatures QGeoServiceProvider::placesFeatures() const
+{
+ const QMetaObject *mo = QGeoServiceProvider::metaObject();
+ const QMetaEnum en = mo->enumerator(
+ mo->indexOfEnumerator("PlacesFeatures"));
+
+ PlacesFeatures ret = NoPlacesFeatures;
+ if (d_ptr->metaData.contains(QStringLiteral("Features"))
+ && d_ptr->metaData.value(QStringLiteral("Features")).isArray()) {
+ QJsonArray features = d_ptr->metaData.value(QStringLiteral("Features")).toArray();
+ foreach (QJsonValue v, features) {
+ int val = en.keyToValue(v.toString().toAscii().constData());
+ if (v.isString() && val != -1) {
+ ret |= PlacesFeature(val);
+ }
+ }
+ }
+
+ return ret;
+}
+
/*!
Returns the QGeocodingManager made available by the service
provider.
@@ -182,7 +272,10 @@ QGeoServiceProvider::~QGeoServiceProvider()
*/
QGeocodingManager* QGeoServiceProvider::geocodingManager() const
{
- if (!d_ptr->factory || (d_ptr->geocodeError != QGeoServiceProvider::NoError))
+ if (!d_ptr->factory)
+ d_ptr->loadPlugin(d_ptr->parameterMap);
+
+ if (!d_ptr->factory || d_ptr->geocodeError != QGeoServiceProvider::NoError)
return 0;
if (!d_ptr->geocodingManager) {
@@ -190,8 +283,10 @@ QGeocodingManager* QGeoServiceProvider::geocodingManager() const
&(d_ptr->geocodeError),
&(d_ptr->geocodeErrorString));
if (engine) {
- engine->setManagerName(d_ptr->factory->providerName());
- engine->setManagerVersion(d_ptr->factory->providerVersion());
+ engine->setManagerName(
+ d_ptr->metaData.value(QStringLiteral("Provider")).toString());
+ engine->setManagerVersion(
+ int(d_ptr->metaData.value(QStringLiteral("Version")).toDouble()));
d_ptr->geocodingManager = new QGeocodingManager(engine);
} else {
d_ptr->geocodeError = QGeoServiceProvider::NotSupportedError;
@@ -205,6 +300,9 @@ QGeocodingManager* QGeoServiceProvider::geocodingManager() const
d_ptr->error = d_ptr->geocodeError;
d_ptr->errorString = d_ptr->geocodeErrorString;
}
+
+ if (d_ptr->geocodingManager && d_ptr->localeSet)
+ d_ptr->geocodingManager->setLocale(d_ptr->locale);
}
if (d_ptr->geocodingManager) {
@@ -237,6 +335,9 @@ QGeocodingManager* QGeoServiceProvider::geocodingManager() const
*/
QGeoMappingManager* QGeoServiceProvider::mappingManager() const
{
+ if (!d_ptr->factory)
+ d_ptr->loadPlugin(d_ptr->parameterMap);
+
if (!d_ptr->factory || (d_ptr->mappingError != QGeoServiceProvider::NoError))
return 0;
@@ -246,8 +347,10 @@ QGeoMappingManager* QGeoServiceProvider::mappingManager() const
&(d_ptr->mappingErrorString));
if (engine) {
- engine->setManagerName(d_ptr->factory->providerName());
- engine->setManagerVersion(d_ptr->factory->providerVersion());
+ engine->setManagerName(
+ d_ptr->metaData.value(QStringLiteral("Provider")).toString());
+ engine->setManagerVersion(
+ int(d_ptr->metaData.value(QStringLiteral("Version")).toDouble()));
d_ptr->mappingManager = new QGeoMappingManager(engine);
} else {
d_ptr->mappingError = QGeoServiceProvider::NotSupportedError;
@@ -261,6 +364,9 @@ QGeoMappingManager* QGeoServiceProvider::mappingManager() const
d_ptr->error = d_ptr->mappingError;
d_ptr->errorString = d_ptr->mappingErrorString;
}
+
+ if (d_ptr->mappingManager && d_ptr->localeSet)
+ d_ptr->mappingManager->setLocale(d_ptr->locale);
}
if (d_ptr->mappingManager) {
@@ -293,6 +399,9 @@ QGeoMappingManager* QGeoServiceProvider::mappingManager() const
*/
QGeoRoutingManager* QGeoServiceProvider::routingManager() const
{
+ if (!d_ptr->factory)
+ d_ptr->loadPlugin(d_ptr->parameterMap);
+
if (!d_ptr->factory || (d_ptr->routingError != QGeoServiceProvider::NoError))
return 0;
@@ -302,8 +411,10 @@ QGeoRoutingManager* QGeoServiceProvider::routingManager() const
&(d_ptr->routingErrorString));
if (engine) {
- engine->setManagerName(d_ptr->factory->providerName());
- engine->setManagerVersion(d_ptr->factory->providerVersion());
+ engine->setManagerName(
+ d_ptr->metaData.value(QStringLiteral("Provider")).toString());
+ engine->setManagerVersion(
+ int(d_ptr->metaData.value(QStringLiteral("Version")).toDouble()));
d_ptr->routingManager = new QGeoRoutingManager(engine);
} else {
d_ptr->routingError = QGeoServiceProvider::NotSupportedError;
@@ -317,6 +428,9 @@ QGeoRoutingManager* QGeoServiceProvider::routingManager() const
d_ptr->error = d_ptr->routingError;
d_ptr->errorString = d_ptr->routingErrorString;
}
+
+ if (d_ptr->routingManager && d_ptr->localeSet)
+ d_ptr->routingManager->setLocale(d_ptr->locale);
}
if (d_ptr->routingManager) {
@@ -348,6 +462,9 @@ QGeoRoutingManager* QGeoServiceProvider::routingManager() const
*/
QPlaceManager *QGeoServiceProvider::placeManager() const
{
+ if (!d_ptr->factory)
+ d_ptr->loadPlugin(d_ptr->parameterMap);
+
if (!d_ptr->factory || (d_ptr->placeError != QGeoServiceProvider::NoError))
return 0;
@@ -357,8 +474,10 @@ QPlaceManager *QGeoServiceProvider::placeManager() const
&(d_ptr->placeErrorString));
if (engine) {
- engine->setManagerName(d_ptr->factory->providerName());
- engine->setManagerVersion(d_ptr->factory->providerVersion());
+ engine->setManagerName(
+ d_ptr->metaData.value(QStringLiteral("Provider")).toString());
+ engine->setManagerVersion(
+ int(d_ptr->metaData.value(QStringLiteral("Version")).toDouble()));
d_ptr->placeManager = new QPlaceManager(engine);
engine->d_ptr->manager = d_ptr->placeManager;
@@ -374,6 +493,9 @@ QPlaceManager *QGeoServiceProvider::placeManager() const
d_ptr->error = d_ptr->placeError;
d_ptr->errorString = d_ptr->placeErrorString;
}
+
+ if (d_ptr->placeManager && d_ptr->localeSet)
+ d_ptr->placeManager->setLocale(d_ptr->locale);
}
if (d_ptr->placeManager) {
@@ -402,11 +524,62 @@ QString QGeoServiceProvider::errorString() const
return d_ptr->errorString;
}
+/*!
+ Sets whether experimental plugins are considered when locating the
+ correct plugin library for this service provider.
+
+ \bold{Important:} this will destroy any existing managers held by this
+ service provider instance. You should be sure not to attempt to use any
+ pointers that you have previously retrieved after calling this method.
+*/
+void QGeoServiceProvider::setAllowExperimental(bool allow)
+{
+ d_ptr->experimental = allow;
+ d_ptr->unload();
+ d_ptr->loadMeta();
+}
+
+/*!
+ Sets the parameters used to construct individual manager classes for
+ this service provider.
+
+ \bold{Important:} this will destroy any existing managers held by this
+ service provider instance. You should be sure not to attempt to use any
+ pointers that you have previously retrieved after calling this method.
+*/
+void QGeoServiceProvider::setParameters(const QMap<QString, QVariant> &parameters)
+{
+ d_ptr->parameterMap = parameters;
+ d_ptr->unload();
+ d_ptr->loadMeta();
+}
+
+/*!
+ Sets the locale used by this service provider. If the relevant features
+ (see LocalizedMappingFeature etc), this will change the languages, units
+ and other locale-specific attributes of the provider's data.
+*/
+void QGeoServiceProvider::setLocale(const QLocale &locale)
+{
+ d_ptr->locale = locale;
+ d_ptr->localeSet = true;
+
+ if (d_ptr->geocodingManager)
+ d_ptr->geocodingManager->setLocale(locale);
+ if (d_ptr->routingManager)
+ d_ptr->routingManager->setLocale(locale);
+ if (d_ptr->mappingManager)
+ d_ptr->mappingManager->setLocale(locale);
+ if (d_ptr->placeManager)
+ d_ptr->placeManager->setLocale(locale);
+}
+
/*******************************************************************************
*******************************************************************************/
QGeoServiceProviderPrivate::QGeoServiceProviderPrivate()
: factory(0),
+ experimental(false),
geocodingManager(0),
routingManager(0),
mappingManager(0),
@@ -415,7 +588,11 @@ QGeoServiceProviderPrivate::QGeoServiceProviderPrivate()
routingError(QGeoServiceProvider::NoError),
mappingError(QGeoServiceProvider::NoError),
placeError(QGeoServiceProvider::NoError),
- error(QGeoServiceProvider::NoError) {}
+ error(QGeoServiceProvider::NoError),
+ localeSet(false)
+{
+ metaData.insert(QStringLiteral("index"), -1);
+}
QGeoServiceProviderPrivate::~QGeoServiceProviderPrivate()
{
@@ -432,93 +609,117 @@ QGeoServiceProviderPrivate::~QGeoServiceProviderPrivate()
delete placeManager;
}
-void QGeoServiceProviderPrivate::loadPlugin(const QString &providerName, const QMap<QString, QVariant> &parameters)
+void QGeoServiceProviderPrivate::unload()
{
- Q_UNUSED(parameters)
+ if (geocodingManager) {
+ delete geocodingManager;
+ geocodingManager = 0;
+ }
- if (!QGeoServiceProviderPrivate::plugins().keys().contains(providerName)) {
- error = QGeoServiceProvider::NotSupportedError;
- errorString = QString(QLatin1String("The geoservices provider %1 is not supported.")).arg(providerName);
- factory = 0;
- return;
+ if (routingManager) {
+ delete routingManager;
+ routingManager = 0;
}
- factory = 0;
+ if (mappingManager) {
+ delete mappingManager;
+ mappingManager = 0;
+ }
+ if (placeManager) {
+ delete placeManager;
+ placeManager = 0;
+ }
+
+ factory = 0;
error = QGeoServiceProvider::NoError;
errorString = QLatin1String("");
+ metaData = QJsonObject();
+ metaData.insert(QStringLiteral("index"), -1);
+}
- QList<QGeoServiceProviderFactory*> candidates = QGeoServiceProviderPrivate::plugins().values(providerName);
+void QGeoServiceProviderPrivate::loadMeta()
+{
+ factory = 0;
+ metaData = QJsonObject();
+ metaData.insert(QStringLiteral("index"), -1);
+ error = QGeoServiceProvider::NotSupportedError;
+ errorString = QString(QLatin1String("The geoservices provider %1 is not supported.")).arg(providerName);
+
+ QList<QJsonObject> candidates = QGeoServiceProviderPrivate::plugins().values(providerName);
int versionFound = -1;
+ int idx = -1;
+ // figure out which version of the plugin we want
+ // (always latest unless experimental)
for (int i = 0; i < candidates.size(); ++i) {
- QGeoServiceProviderFactory* f = candidates[i];
- if (f && (f->providerVersion() > versionFound)) {
- versionFound = f->providerVersion();
- factory = f;
+ QJsonObject meta = candidates[i];
+ if (meta.contains(QStringLiteral("Version"))
+ && meta.value(QStringLiteral("Version")).isDouble()
+ && meta.contains(QStringLiteral("Experimental"))
+ && meta.value(QStringLiteral("Experimental")).isBool()) {
+ int ver = int(meta.value(QStringLiteral("Version")).toDouble());
+ if (ver > versionFound && !(!experimental && meta.value(QStringLiteral("Experimental")).toBool())) {
+ versionFound = ver;
+ idx = i;
+ }
}
}
+
+ if (idx != -1) {
+ error = QGeoServiceProvider::NoError;
+ errorString = QStringLiteral("");
+ metaData = candidates[idx];
+ }
}
-QHash<QString, QGeoServiceProviderFactory*> QGeoServiceProviderPrivate::plugins(bool reload)
+void QGeoServiceProviderPrivate::loadPlugin(const QMap<QString, QVariant> &parameters)
{
- static QHash<QString, QGeoServiceProviderFactory*> plugins;
+ Q_UNUSED(parameters)
+
+ if (int(metaData.value(QStringLiteral("index")).toDouble()) < 0) {
+ error = QGeoServiceProvider::NotSupportedError;
+ errorString = QString(QLatin1String("The geoservices provider is not supported."));
+ factory = 0;
+ return;
+ }
+
+ error = QGeoServiceProvider::NoError;
+ errorString = QLatin1String("");
+
+ int idx = int(metaData.value(QStringLiteral("index")).toDouble());
+
+ // load the actual plugin (BWAHAHA)
+ factory = qobject_cast<QGeoServiceProviderFactory*>(loader()->instance(idx));
+}
+
+QHash<QString, QJsonObject> QGeoServiceProviderPrivate::plugins(bool reload)
+{
+ static QHash<QString, QJsonObject> plugins;
static bool alreadyDiscovered = false;
if (reload == true)
alreadyDiscovered = false;
if (!alreadyDiscovered) {
- loadStaticPlugins(&plugins);
- loadDynamicPlugins(&plugins);
+ loadPluginMetadata(plugins);
alreadyDiscovered = true;
}
return plugins;
}
-void QGeoServiceProviderPrivate::loadDynamicPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins)
+void QGeoServiceProviderPrivate::loadPluginMetadata(QHash<QString, QJsonObject> &list)
{
QFactoryLoader *l = loader();
- QString key;
- for (int i = 0; i < l->keys().count(); i++) {
- key = l->keys().at(i);
- QGeoServiceProviderFactory *f = qobject_cast<QGeoServiceProviderFactory*>(l->instance(key));
- if (f) {
- const QString name = f->providerName();
-#if !defined QT_NO_DEBUG
- const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
- if (showDebug)
- qDebug() << "Dynamic: found a service provider plugin with name" << name;
-#endif
- plugins->insertMulti(name, f);
- }
+ QList<QJsonObject> meta = l->metaData();
+ for (int i = 0; i < meta.size(); i++) {
+ QJsonObject obj = meta.at(i).value(QStringLiteral("MetaData")).toObject();
+ obj.insert(QStringLiteral("index"), i);
+ list.insertMulti(obj.value(QStringLiteral("Provider")).toString(), obj);
}
}
-void QGeoServiceProviderPrivate::loadStaticPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins)
-{
-#if !defined QT_NO_DEBUG
- const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
-#endif
-
- QObjectList staticPlugins = QPluginLoader::staticInstances();
- for (int i = 0; i < staticPlugins.count(); ++i) {
- QGeoServiceProviderFactory *f = qobject_cast<QGeoServiceProviderFactory*>(staticPlugins.at(i));
- if (f) {
- QString name = f->providerName();
-
-#if !defined QT_NO_DEBUG
- if (showDebug)
- qDebug() << "Static: found a service provider plugin with name" << name;
-#endif
- if (!name.isEmpty()) {
- plugins->insertMulti(name, f);
- }
- }
-
- }
-}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeoserviceprovider.h b/src/location/maps/qgeoserviceprovider.h
index 6f8eb9b6..6d5a0281 100644
--- a/src/location/maps/qgeoserviceprovider.h
+++ b/src/location/maps/qgeoserviceprovider.h
@@ -45,6 +45,7 @@
#include <QMap>
#include <QVariant>
#include <QString>
+#include <QObject>
#include <QtLocation/qlocationglobal.h>
@@ -52,8 +53,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
-
+class QLocale;
class QStringList;
class QGeocodingManager;
class QGeoMappingManager;
@@ -65,8 +65,10 @@ class QGeoRoutingManagerEngine;
class QPlaceManagerEngine;
class QGeoServiceProviderPrivate;
-class Q_LOCATION_EXPORT QGeoServiceProvider
+class Q_LOCATION_EXPORT QGeoServiceProvider : public QObject
{
+ Q_OBJECT
+
public:
enum Error {
NoError,
@@ -76,12 +78,75 @@ public:
ConnectionError
};
+ enum RoutingFeature {
+ NoRoutingFeatures = 0,
+ OnlineRoutingFeature = (1<<0),
+ OfflineRoutingFeature = (1<<1),
+ LocalizedRoutingFeature = (1<<2),
+ RouteUpdatesFeature = (1<<3),
+ AlternativeRoutesFeature = (1<<4),
+ ExcludeAreasRoutingFeature = (1<<5),
+ AnyRoutingFeatures = ~(0)
+ };
+
+ enum GeocodingFeature {
+ NoGeocodingFeatures = 0,
+ OnlineGeocodingFeature = (1<<0),
+ OfflineGeocodingFeature = (1<<1),
+ ReverseGeocodingFeature = (1<<2),
+ LocalizedGeocodingFeature = (1<<3),
+ AnyGeocodingFeatures = ~(0)
+ };
+
+ enum MappingFeature {
+ NoMappingFeatures = 0,
+ OnlineMappingFeature = (1<<0),
+ OfflineMappingFeature = (1<<1),
+ LocalizedMappingFeature = (1<<2),
+ AnyMappingFeatures = ~(0)
+ };
+
+ enum PlacesFeature {
+ NoPlacesFeatures = 0,
+ OnlinePlacesFeature = (1<<0),
+ OfflinePlacesFeature = (1<<1),
+ SavePlaceFeature = (1<<2),
+ RemovePlaceFeature = (1<<3),
+ SaveCategoryFeature = (1<<4),
+ RemoveCategoryFeature = (1<<5),
+ PlaceRecommendationsFeature = (1<<6),
+ SearchSuggestionsFeature = (1<<7),
+ CorrectionsFeature = (1<<8),
+ LocalizedPlacesFeature = (1<<9),
+ NotificationsFeature = (1<<10),
+ PlaceMatchingFeature = (1<<11),
+ AnyPlacesFeatures = ~(0)
+ };
+
+ Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)
+ Q_FLAGS(RoutingFeatures)
+
+ Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)
+ Q_FLAGS(GeocodingFeatures)
+
+ Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)
+ Q_FLAGS(MappingFeatures)
+
+ Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)
+ Q_FLAGS(PlacesFeatures)
+
static QStringList availableServiceProviders();
QGeoServiceProvider(const QString &providerName,
- const QMap<QString,QVariant> &parameters = (QMap<QString,QVariant>()));
+ const QMap<QString,QVariant> &parameters = (QMap<QString,QVariant>()),
+ bool allowExperimental = false);
~QGeoServiceProvider();
+ RoutingFeatures routingFeatures() const;
+ GeocodingFeatures geocodingFeatures() const;
+ MappingFeatures mappingFeatures() const;
+ PlacesFeatures placesFeatures() const;
+
QGeocodingManager* geocodingManager() const;
QGeoMappingManager* mappingManager() const;
QGeoRoutingManager* routingManager() const;
@@ -90,6 +155,10 @@ public:
Error error() const;
QString errorString() const;
+ void setParameters(const QMap<QString, QVariant> &parameters);
+ void setLocale(const QLocale &locale);
+ void setAllowExperimental(bool allow);
+
private:
QGeoServiceProviderPrivate* d_ptr;
};
diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h
index 812e7948..191f3517 100644
--- a/src/location/maps/qgeoserviceprovider_p.h
+++ b/src/location/maps/qgeoserviceprovider_p.h
@@ -56,6 +56,9 @@
#include "qgeoserviceprovider.h"
#include <QHash>
+#include <QJsonObject>
+#include <QJsonArray>
+#include <QLocale>
QT_BEGIN_NAMESPACE
@@ -71,12 +74,16 @@ public:
QGeoServiceProviderPrivate();
~QGeoServiceProviderPrivate();
- void loadPlugin(const QString &providerName, const QMap<QString, QVariant> &parameters);
-
+ void loadMeta();
+ void loadPlugin(const QMap<QString, QVariant> &parameters);
+ void unload();
QGeoServiceProviderFactory *factory;
+ QJsonObject metaData;
QMap<QString, QVariant> parameterMap;
+ bool experimental;
+
QGeocodingManager *geocodingManager;
QGeoRoutingManager *routingManager;
QGeoMappingManager *mappingManager;
@@ -95,9 +102,13 @@ public:
QGeoServiceProvider::Error error;
QString errorString;
- static QHash<QString, QGeoServiceProviderFactory*> plugins(bool reload = false);
- static void loadDynamicPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins);
- static void loadStaticPlugins(QHash<QString, QGeoServiceProviderFactory*> *plugins);
+ QString providerName;
+
+ QLocale locale;
+ bool localeSet;
+
+ static QHash<QString, QJsonObject> plugins(bool reload = false);
+ static void loadPluginMetadata(QHash<QString, QJsonObject> &list);
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeoserviceproviderfactory.cpp b/src/location/maps/qgeoserviceproviderfactory.cpp
index 170ff77c..6761d762 100644
--- a/src/location/maps/qgeoserviceproviderfactory.cpp
+++ b/src/location/maps/qgeoserviceproviderfactory.cpp
@@ -65,25 +65,6 @@ QT_BEGIN_NAMESPACE
Destroys this QGeoServiceProviderFactory instance.
*/
-
-/*!
-\fn QString QGeoServiceProviderFactory::providerName() const
-
-Returns the string used to identify the service provider behind this implementation.
-
-The combination of providerName() and providerVersion() should be unique
-amongst the plugins.
-*/
-
-/*!
-\fn int QGeoServiceProviderFactory::providerVersion() const
-
-Returns the version of the plugin.
-
-The combination of providerName() and providerVersion() should be unique
-amongst the plugins.
-*/
-
/*!
Returns a new QGeocodingManagerEngine instance, initialized with \a
parameters, which implements the location geocoding functionality.
diff --git a/src/location/maps/qgeoserviceproviderfactory.h b/src/location/maps/qgeoserviceproviderfactory.h
index 362349e2..7e93d0b4 100644
--- a/src/location/maps/qgeoserviceproviderfactory.h
+++ b/src/location/maps/qgeoserviceproviderfactory.h
@@ -47,22 +47,16 @@
#include <QtPlugin>
#include <QMap>
#include <QString>
-#include <QFactoryInterface>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
-
-class Q_LOCATION_EXPORT QGeoServiceProviderFactory : public QFactoryInterface
+class Q_LOCATION_EXPORT QGeoServiceProviderFactory
{
public:
virtual ~QGeoServiceProviderFactory() {}
- virtual QString providerName() const = 0;
- virtual int providerVersion() const = 0;
-
virtual QGeocodingManagerEngine* createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
@@ -77,8 +71,8 @@ public:
QString *errorString) const;
};
-#define QT_GEOSERVICE_BACKEND_INTERFACE "com.nokia.qt.geoservice.serviceproviderfactory/1.0"
-Q_DECLARE_INTERFACE(QGeoServiceProviderFactory, QT_GEOSERVICE_BACKEND_INTERFACE);
+Q_DECLARE_INTERFACE(QGeoServiceProviderFactory,
+ "org.qt-project.qt.geoservice.serviceproviderfactory/5.0");
QT_END_NAMESPACE
diff --git a/src/location/places/qplacemanager.cpp b/src/location/places/qplacemanager.cpp
index cfbb5137..d1f53d69 100644
--- a/src/location/places/qplacemanager.cpp
+++ b/src/location/places/qplacemanager.cpp
@@ -399,14 +399,6 @@ QPlace QPlaceManager::compatiblePlace(const QPlace &original)
}
/*!
- Returns a set of flags indicating what particular features this manager instance supports.
-*/
-QPlaceManager::ManagerFeatures QPlaceManager::supportedFeatures() const
-{
- return d->supportedFeatures();
-}
-
-/*!
Returns a reply which contains a list of places which correspond/match those
specified in the \a request. The places specified in the request come from a
different manager.
diff --git a/src/location/places/qplacemanager.h b/src/location/places/qplacemanager.h
index 7419658a..36e53415 100644
--- a/src/location/places/qplacemanager.h
+++ b/src/location/places/qplacemanager.h
@@ -72,23 +72,6 @@ class Q_LOCATION_EXPORT QPlaceManager : public QObject
{
Q_OBJECT
public:
- enum ManagerFeature {
- NoFeatures = 0x0,
- SavePlaceFeature = 0x1,
- RemovePlaceFeature = 0x2,
- SaveCategoryFeature = 0x4,
- RemoveCategoryFeature = 0x8,
- RecommendationsFeature = 0x10,
- SearchSuggestionsFeature = 0x20,
- CorrectionsFeature = 0x40,
- LocaleFeature = 0x80,
- NotificationsFeature = 0x100,
- MatchingFeature = 0x200
- };
-
- Q_DECLARE_FLAGS(ManagerFeatures, ManagerFeature)
- Q_FLAGS(ManagerFeatures)
-
~QPlaceManager();
QString managerName() const;
@@ -123,8 +106,6 @@ public:
QPlace compatiblePlace(const QPlace &place);
- ManagerFeatures supportedFeatures() const;
-
QPlaceMatchReply *matchingPlaces(const QPlaceMatchRequest &request) const;
Q_SIGNALS:
@@ -149,8 +130,6 @@ private:
friend class QPlaceIcon;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QPlaceManager::ManagerFeatures)
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/location/places/qplacemanagerengine.cpp b/src/location/places/qplacemanagerengine.cpp
index c2602521..0c076a37 100644
--- a/src/location/places/qplacemanagerengine.cpp
+++ b/src/location/places/qplacemanagerengine.cpp
@@ -345,15 +345,6 @@ QPlace QPlaceManagerEngine::compatiblePlace(const QPlace &original) const
}
/*!
- Returns a set of flags indicating what particular features this manager engine instance
- supports.
-*/
-QPlaceManager::ManagerFeatures QPlaceManagerEngine::supportedFeatures() const
-{
- return QPlaceManager::NoFeatures;
-}
-
-/*!
Returns a reply which contains a list of places which correspond/match those
specified in \a request.
*/
diff --git a/src/location/places/qplacemanagerengine.h b/src/location/places/qplacemanagerengine.h
index 9d3f14ed..66ee4f30 100644
--- a/src/location/places/qplacemanagerengine.h
+++ b/src/location/places/qplacemanagerengine.h
@@ -92,8 +92,6 @@ public:
virtual QPlace compatiblePlace(const QPlace &original) const;
- virtual QPlaceManager::ManagerFeatures supportedFeatures() const;
-
virtual QPlaceMatchReply *matchingPlaces(const QPlaceMatchRequest &request);
Q_SIGNALS:
diff --git a/src/plugins/geoservices/nokia/nokia.pro b/src/plugins/geoservices/nokia/nokia.pro
index 902c0cca..06b051fa 100644
--- a/src/plugins/geoservices/nokia/nokia.pro
+++ b/src/plugins/geoservices/nokia/nokia.pro
@@ -48,3 +48,6 @@ INCLUDEPATH += ../../../location/maps
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+OTHER_FILES += \
+ nokia_plugin.json
+
diff --git a/src/plugins/geoservices/nokia/nokia_plugin.json b/src/plugins/geoservices/nokia/nokia_plugin.json
new file mode 100644
index 00000000..d8abb0f2
--- /dev/null
+++ b/src/plugins/geoservices/nokia/nokia_plugin.json
@@ -0,0 +1,20 @@
+{
+ "Keys": ["nokia"],
+ "Provider": "nokia",
+ "Version": 100,
+ "Experimental": false,
+ "Features": [
+ "OnlineRoutingFeature",
+ "RouteUpdatesFeature",
+ "AlternativeRoutesFeature",
+ "ExcludeAreasRoutingFeature",
+ "OnlineGeocodingFeature",
+ "OnlineMappingFeature",
+ "OnlinePlacesFeature",
+ "ReverseGeocodingFeature",
+ "PlaceRecommendationsFeature",
+ "SearchSuggestionsFeature",
+ "CorrectionsFeature",
+ "LocalizedPlacesFeature"
+ ]
+}
diff --git a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
index dad8d507..3201f73e 100644
--- a/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeocodingmanagerengine_nokia.cpp
@@ -98,10 +98,6 @@ QGeocodingManagerEngineNokia::QGeocodingManagerEngineNokia(const QMap<QString, Q
m_token = parameters.value("token").toString();
}
-
- setSupportsGeocoding(true);
- setSupportsReverseGeocoding(true);
-
if (error)
*error = QGeoServiceProvider::NoError;
@@ -114,12 +110,6 @@ QGeocodingManagerEngineNokia::~QGeocodingManagerEngineNokia() {}
QGeocodeReply* QGeocodingManagerEngineNokia::geocode(const QGeoAddress &address,
const QGeoBoundingArea &bounds)
{
- if (!supportsGeocoding()) {
- QGeocodeReply *reply = new QGeocodeReply(QGeocodeReply::UnsupportedOptionError, "Geocoding is not supported by this service provider.", this);
- emit error(reply, reply->error(), reply->errorString());
- return reply;
- }
-
QString requestString = "http://";
requestString += m_host;
requestString += "/geocoder/gc/2.0?referer=" + m_referer;
@@ -170,12 +160,6 @@ QGeocodeReply* QGeocodingManagerEngineNokia::geocode(const QGeoAddress &address,
QGeocodeReply* QGeocodingManagerEngineNokia::reverseGeocode(const QGeoCoordinate &coordinate,
const QGeoBoundingArea &bounds)
{
- if (!supportsReverseGeocoding()) {
- QGeocodeReply *reply = new QGeocodeReply(QGeocodeReply::UnsupportedOptionError, "Reverse geocoding is not supported by this service provider.", this);
- emit error(reply, reply->error(), reply->errorString());
- return reply;
- }
-
QString requestString = "http://";
requestString += m_host;
requestString += "/geocoder/rgc/2.0?referer=" + m_referer;
diff --git a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
index 6a3955dc..ab9e156e 100644
--- a/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoroutingmanagerengine_nokia.cpp
@@ -69,7 +69,7 @@ QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(const QMap<QString,
if (!proxy.isEmpty()) {
QUrl proxyUrl(proxy);
if (proxyUrl.isValid()) {
- m_networkManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
+ m_networkManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
proxyUrl.host(),
proxyUrl.port(8080),
proxyUrl.userName(),
@@ -95,10 +95,6 @@ QGeoRoutingManagerEngineNokia::QGeoRoutingManagerEngineNokia(const QMap<QString,
m_token = parameters.value("token").toString();
}
- setSupportsRouteUpdates(true);
- setSupportsAlternativeRoutes(true);
- setSupportsExcludeAreas(true);
-
QGeoRouteRequest::FeatureTypes featureTypes;
featureTypes |= QGeoRouteRequest::TollFeature;
featureTypes |= QGeoRouteRequest::HighwayFeature;
@@ -232,9 +228,6 @@ QString QGeoRoutingManagerEngineNokia::calculateRouteRequestString(const QGeoRou
{
bool supported = checkEngineSupport(request, request.travelModes());
- if ((request.numberAlternativeRoutes() != 0) && !supportsAlternativeRoutes())
- supported = false;
-
if (!supported)
return "";
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
index da0f45a8..7fd08bae 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.cpp
@@ -63,21 +63,6 @@ QGeoServiceProviderFactoryNokia::QGeoServiceProviderFactoryNokia() {}
QGeoServiceProviderFactoryNokia::~QGeoServiceProviderFactoryNokia() {}
-QString QGeoServiceProviderFactoryNokia::providerName() const
-{
- return "nokia";
-}
-
-QStringList QGeoServiceProviderFactoryNokia::keys() const
-{
- return QStringList() << QLatin1String("nokia");
-}
-
-int QGeoServiceProviderFactoryNokia::providerVersion() const
-{
- return 1;
-}
-
QGeocodingManagerEngine* QGeoServiceProviderFactoryNokia::createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
@@ -116,6 +101,4 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryNokia::createPlaceManagerEngine(c
const QString QGeoServiceProviderFactoryNokia::defaultToken("152022572f0e44e07489c35cd46fa246");
const QString QGeoServiceProviderFactoryNokia::defaultReferer("qtlocationapi");
-Q_EXPORT_PLUGIN2(qtgeoservices_nokia, QGeoServiceProviderFactoryNokia)
-
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
index 158fc15f..52acea36 100644
--- a/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
+++ b/src/plugins/geoservices/nokia/qgeoserviceproviderplugin_nokia.h
@@ -57,15 +57,14 @@ QT_BEGIN_NAMESPACE
class QGeoServiceProviderFactoryNokia : public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "nokia_plugin.json")
+
public:
QGeoServiceProviderFactoryNokia();
~QGeoServiceProviderFactoryNokia();
- QString providerName() const;
- int providerVersion() const;
- QStringList keys() const;
-
QGeocodingManagerEngine* createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp
index 8d622d72..cc3db994 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.cpp
@@ -309,15 +309,6 @@ void QPlaceManagerEngineNokiaV1::setLocales(const QList<QLocale> &locales)
QPlaceRestManager::instance()->setLocales(locales);
}
-
-QPlaceManager::ManagerFeatures QPlaceManagerEngineNokiaV1::supportedFeatures() const
-{
- return QPlaceManager::RecommendationsFeature
- | QPlaceManager::SearchSuggestionsFeature
- | QPlaceManager::CorrectionsFeature
- | QPlaceManager::LocaleFeature;
-}
-
void QPlaceManagerEngineNokiaV1::processingError(QPlaceReply *reply,
const QPlaceReply::Error &errorId,
const QString &errorMessage)
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h
index 08bc30cb..436c3e6c 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav1.h
@@ -91,8 +91,6 @@ public:
QList<QLocale> locales() const;
void setLocales(const QList<QLocale> &locales);
- QPlaceManager::ManagerFeatures supportedFeatures() const;
-
private slots:
void processingError(QPlaceReply *reply, const QPlaceReply::Error &error, const QString &errorMessage);
void processingFinished(QPlaceReply *reply);
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
index 7026717d..1a7fcc8d 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp
@@ -499,13 +499,6 @@ void QPlaceManagerEngineNokiaV2::setLocales(const QList<QLocale> &locales)
m_locales = locales;
}
-QPlaceManager::ManagerFeatures QPlaceManagerEngineNokiaV2::supportedFeatures() const
-{
- return QPlaceManager::RecommendationsFeature |
- QPlaceManager::SearchSuggestionsFeature |
- QPlaceManager::LocaleFeature;
-}
-
void QPlaceManagerEngineNokiaV2::replyFinished()
{
QPlaceReply *reply = qobject_cast<QPlaceReply *>(sender());
diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
index a9afbb9a..526f5bbe 100644
--- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
+++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.h
@@ -105,8 +105,6 @@ public:
QList<QLocale> locales() const;
void setLocales(const QList<QLocale> &locales);
- QPlaceManager::ManagerFeatures supportedFeatures() const;
-
private:
QNetworkReply *sendRequest(const QUrl &url);
QByteArray createLanguageString() const;
diff --git a/src/plugins/geoservices/nokia_places_jsondb/nokia_places_jsondb.pro b/src/plugins/geoservices/nokia_places_jsondb/nokia_places_jsondb.pro
index 5e96bb36..6893f21f 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/nokia_places_jsondb.pro
+++ b/src/plugins/geoservices/nokia_places_jsondb/nokia_places_jsondb.pro
@@ -39,3 +39,6 @@ QT += jsondb
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+
+OTHER_FILES += \
+ nokia_plugin_jsondb.json
diff --git a/src/plugins/geoservices/nokia_places_jsondb/nokia_plugin_jsondb.json b/src/plugins/geoservices/nokia_places_jsondb/nokia_plugin_jsondb.json
new file mode 100644
index 00000000..90b89076
--- /dev/null
+++ b/src/plugins/geoservices/nokia_places_jsondb/nokia_plugin_jsondb.json
@@ -0,0 +1,14 @@
+{
+ "Keys": ["nokia_places_jsondb"],
+ "Provider": "nokia_places_jsondb",
+ "Version": 100,
+ "Experimental": false,
+ "Features": [
+ "OfflinePlacesFeature",
+ "SavePlaceFeature",
+ "RemovePlaceFeature",
+ "SaveCategoryFeature",
+ "RemoveCategoryFeature",
+ "PlaceMatchingFeature"
+ ]
+}
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.cpp b/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.cpp
index 38252582..4c2bd548 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.cpp
+++ b/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.cpp
@@ -51,21 +51,6 @@ QGeoServiceProviderFactoryJsonDb::QGeoServiceProviderFactoryJsonDb() {}
QGeoServiceProviderFactoryJsonDb::~QGeoServiceProviderFactoryJsonDb() {}
-QString QGeoServiceProviderFactoryJsonDb::providerName() const
-{
- return QLatin1String("nokia_places_jsondb");
-}
-
-QStringList QGeoServiceProviderFactoryJsonDb::keys() const
-{
- return QStringList() << QLatin1String("nokia_places_jsondb");
-}
-
-int QGeoServiceProviderFactoryJsonDb::providerVersion() const
-{
- return 1;
-}
-
QGeocodingManagerEngine* QGeoServiceProviderFactoryJsonDb::createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const
@@ -106,6 +91,4 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryJsonDb::createPlaceManagerEngine(
return new QPlaceManagerEngineJsonDb(parameters, error, errorString);
}
-Q_EXPORT_PLUGIN2(qtgeoservices_nokia_places_jsondb, QGeoServiceProviderFactoryJsonDb)
-
QT_END_NAMESPACE
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.h b/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.h
index 3674fb6e..59a19abb 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.h
+++ b/src/plugins/geoservices/nokia_places_jsondb/qgeoserviceproviderplugin_jsondb.h
@@ -50,16 +50,14 @@ QT_BEGIN_NAMESPACE
class QGeoServiceProviderFactoryJsonDb : public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "nokia_plugin_jsondb.json")
+
public:
QGeoServiceProviderFactoryJsonDb();
~QGeoServiceProviderFactoryJsonDb();
- QString providerName() const;
- int providerVersion() const;
-
- QStringList keys() const;
-
QGeocodingManagerEngine* createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
index 7a08b47c..cf257ff5 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
+++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.cpp
@@ -307,15 +307,6 @@ QUrl QPlaceManagerEngineJsonDb::constructIconUrl(const QPlaceIcon &icon, const Q
return QUrl();
}
-QPlaceManager::ManagerFeatures QPlaceManagerEngineJsonDb::supportedFeatures() const
-{
- return QPlaceManager::SavePlaceFeature |
- QPlaceManager::RemovePlaceFeature |
- QPlaceManager::SaveCategoryFeature |
- QPlaceManager::RemoveCategoryFeature |
- QPlaceManager::MatchingFeature;
-}
-
QPlaceMatchReply * QPlaceManagerEngineJsonDb::matchingPlaces(const QPlaceMatchRequest &request)
{
MatchReply *reply = new MatchReply(this);
diff --git a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
index 79863039..388aaa97 100644
--- a/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
+++ b/src/plugins/geoservices/nokia_places_jsondb/qplacemanagerengine_jsondb.h
@@ -103,7 +103,6 @@ public:
QPlace compatiblePlace(const QPlace &original) const;
QUrl constructIconUrl(const QPlaceIcon &icon, const QSize &size) const;
- QPlaceManager::ManagerFeatures supportedFeatures() const;
JsonDb *db() { return m_jsonDb;}
QPlaceManager *manager() const { return QPlaceManagerEngine::manager(); }
diff --git a/tests/auto/declarative_core/tst_plugin.qml b/tests/auto/declarative_core/tst_plugin.qml
index 683a028d..32ba7e1c 100644
--- a/tests/auto/declarative_core/tst_plugin.qml
+++ b/tests/auto/declarative_core/tst_plugin.qml
@@ -45,6 +45,7 @@ import QtLocation 5.0
Item {
+ Plugin { id: unattachedPlugin }
Plugin { id: nokiaPlugin; name: "nokia"}
Plugin { id: invalidPlugin; name: "invalid"}
Plugin { id: testPlugin;
@@ -56,9 +57,15 @@ Item {
PluginParameter { name: "validateWellKnownValues"; value: true}
]
}
- Plugin { id: requiredPlugin; required: Plugin.MappingFeature | Plugin.GeocodingFeature }
- SignalSpy {id: invalidFeaturesSpy; target: invalidPlugin; signalName: "supportedFeaturesChanged"}
- SignalSpy {id: invalidSupportedPlacesFeaturesSpy; target: invalidPlugin; signalName: "supportedPlacesFeaturesChanged"}
+ SignalSpy {id: invalidAttachedSpy; target: invalidPlugin; signalName: "attached"}
+
+ Plugin { id: requiredPlugin;
+ required {
+ mapping: Plugin.OfflineMappingFeature;
+ geocoding: Plugin.OfflineGeocodingFeature;
+ places: Plugin.AnyPlacesFeatures;
+ }
+ }
TestCase {
name: "Plugin properties"
@@ -67,68 +74,65 @@ Item {
verify (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) // at least test plugin must be present
// invalid plugins should have no features
- compare(invalidPlugin.supported, Plugin.NoFeatures)
+ verify(invalidPlugin.isAttached)
+ verify(!(invalidPlugin.supportsMapping()))
+ verify(!(invalidPlugin.supportsGeocoding()))
+ verify(!(invalidPlugin.supportsRouting()))
+ verify(!(invalidPlugin.supportsPlaces()))
if (invalidPlugin.availableServiceProviders.indexOf('qmlgeo.test.plugin') > -1) {
- var nokiaFeatures = (Plugin.GeocodingFeature |
- Plugin.ReverseGeocodingFeature |
- Plugin.RoutingFeature |
- Plugin.MappingFeature |
- Plugin.AnyPlacesFeature)
- compare(nokiaPlugin.supported & nokiaFeatures, nokiaFeatures)
+ verify(testPlugin.isAttached)
+ verify(testPlugin.supportsMapping())
+ verify(testPlugin.supportsGeocoding())
+ verify(testPlugin.supportsPlaces())
+ verify(testPlugin.supportsRouting())
}
- var testFeatures = (Plugin.GeocodingFeature |
- Plugin.ReverseGeocodingFeature |
- Plugin.RoutingFeature |
- Plugin.MappingFeature |
- Plugin.AnyPlacesFeature)
- compare(testPlugin.supported & testFeatures, testFeatures)
+ if (invalidPlugin.availableServiceProviders.indexOf('nokia')) {
+ verify(nokiaPlugin.isAttached)
+ verify(nokiaPlugin.supportsMapping(Plugin.OnlineMappingFeature))
+ verify(nokiaPlugin.supportsGeocoding(Plugin.OnlineGeocodingFeature))
+ verify(nokiaPlugin.supportsRouting(Plugin.OnlineRoutingFeature))
+ }
+
+ verify(!unattachedPlugin.isAttached)
// test changing name of plugin
- invalidFeaturesSpy.clear()
- compare(invalidFeaturesSpy.count, 0)
+ invalidAttachedSpy.clear()
+ compare(invalidAttachedSpy.count, 0)
invalidPlugin.name = 'qmlgeo.test.plugin'
- compare(invalidFeaturesSpy.count, 1)
- compare(invalidPlugin.supported & testFeatures, testFeatures)
+ tryCompare(invalidAttachedSpy, 'count', 1)
+ verify(invalidPlugin.isAttached)
+
+ verify(invalidPlugin.supportsMapping())
+ verify(invalidPlugin.supportsGeocoding())
+ verify(invalidPlugin.supportsRouting())
+ verify(invalidPlugin.supportsPlaces())
invalidPlugin.name = ''
- compare(invalidFeaturesSpy.count, 2)
+ compare(invalidAttachedSpy.count, 2)
- compare(invalidPlugin.supported, Plugin.NoFeatures)
+ verify(!invalidPlugin.supportsMapping())
+ verify(!invalidPlugin.supportsGeocoding())
+ verify(!invalidPlugin.supportsRouting())
+ verify(!invalidPlugin.supportsPlaces())
}
function test_required() {
// the required plugin should either get nokia or qmlgeo.test.plugin
// either way the name will be non-empty and it'll meet the spec
verify(requiredPlugin.name !== "")
- verify((requiredPlugin.supported & requiredPlugin.required) === requiredPlugin.required)
+ verify(requiredPlugin.supportsMapping(requiredPlugin.required.mapping))
+ verify(requiredPlugin.supportsGeocoding(requiredPlugin.required.geocoding))
+ verify(requiredPlugin.supportsPlaces(requiredPlugin.required.places))
}
function test_placesFeatures() {
- verify((testPlugin.supportedPlacesFeatures & Plugin.SavePlaceFeature) === Plugin.SavePlaceFeature);
- verify((testPlugin.supportedPlacesFeatures & Plugin.SaveCategoryFeature) === Plugin.SaveCategoryFeature);
- verify((testPlugin.supportedPlacesFeatures & Plugin.SearchSuggestionsFeature) === Plugin.SearchSuggestionsFeature);
- verify((testPlugin.supportedPlacesFeatures & Plugin.CorrectionsFeature) === 0);
- verify((testPlugin.supportedPlacesFeatures & Plugin.RemovePlaceFeature) === 0);
-
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SavePlaceFeature) === 0);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RemovePlaceFeature) === 0);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SaveCategoryFeature) === 0);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RemoveCategoryFeature) === 0);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.RecommendationsFeature) === Plugin.RecommendationsFeature);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.SearchSuggestionsFeature) === Plugin.SearchSuggestionsFeature);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.CorrectionsFeature) === Plugin.CorrectionsFeature);
- verify((nokiaPlugin.supportedPlacesFeatures & Plugin.LocaleFeature) === Plugin.LocaleFeature);
-
- invalidSupportedPlacesFeaturesSpy.clear();
- invalidPlugin.name = 'qmlgeo.test.plugin';
- compare(invalidSupportedPlacesFeaturesSpy.count, 1);
- invalidPlugin.name = '';
- compare(invalidSupportedPlacesFeaturesSpy.count, 2);
-
- invalidFeaturesSpy.clear();
- invalidSupportedPlacesFeaturesSpy.clear();
+ verify(testPlugin.supportsPlaces(Plugin.SavePlaceFeature))
+ verify(testPlugin.supportsPlaces(Plugin.SaveCategoryFeature))
+ verify(testPlugin.supportsPlaces(Plugin.SearchSuggestionsFeature))
+ verify(!testPlugin.supportsPlaces(Plugin.CorrectionsFeature))
+ verify(!testPlugin.supportsPlaces(Plugin.RemovePlaceFeature))
}
function test_locale() {
diff --git a/tests/auto/geotestplugin/geotestplugin.json b/tests/auto/geotestplugin/geotestplugin.json
new file mode 100644
index 00000000..a43e43c7
--- /dev/null
+++ b/tests/auto/geotestplugin/geotestplugin.json
@@ -0,0 +1,19 @@
+{
+ "Keys": ["qmlgeo.test.plugin"],
+ "Provider": "qmlgeo.test.plugin",
+ "Version": 100,
+ "Experimental": false,
+ "Features": [
+ "OfflineMappingFeature",
+ "OfflineRoutingFeature",
+ "AlternativeRoutesFeature",
+ "ExcludeAreasRoutingFeature",
+ "RouteUpdatesFeature",
+ "OfflineGeocodingFeature",
+ "ReverseGeocodingFeature",
+ "OfflinePlacesFeature",
+ "SavePlaceFeature",
+ "SaveCategoryFeature",
+ "SearchSuggestionsFeature"
+ ]
+}
diff --git a/tests/auto/geotestplugin/geotestplugin.pro b/tests/auto/geotestplugin/geotestplugin.pro
index d12454fc..bfed371b 100644
--- a/tests/auto/geotestplugin/geotestplugin.pro
+++ b/tests/auto/geotestplugin/geotestplugin.pro
@@ -17,3 +17,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+
+OTHER_FILES += \
+ geotestplugin.json
diff --git a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
index 51fe3dd0..78914c61 100644
--- a/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeocodingmanagerengine_test.h
@@ -100,8 +100,6 @@ public:
if (parameters.contains("validateWellKnownValues"))
validateWellKnownValues_ = qvariant_cast<bool>(parameters.value("validateWellKnownValues"));
- setSupportsGeocoding(supported_);
- setSupportsReverseGeocoding(supported_);
setLocale(QLocale (QLocale::German, QLocale::Germany));
}
diff --git a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
index e672782a..9cf3b847 100644
--- a/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/geotestplugin/qgeoroutingmanagerengine_test.h
@@ -120,9 +120,6 @@ public:
QGeoRouteRequest::CarTravel | QGeoRouteRequest::PedestrianTravel |
QGeoRouteRequest::BicycleTravel | QGeoRouteRequest::PublicTransitTravel |
QGeoRouteRequest::TruckTravel );
- setSupportsAlternativeRoutes ( true );
- setSupportsExcludeAreas ( true );
- setSupportsRouteUpdates ( true );
}
virtual QGeoRouteReply* calculateRoute(const QGeoRouteRequest& request)
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
index dc79e90c..5b5b095a 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.cpp
@@ -55,21 +55,6 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
{
}
-QString QGeoServiceProviderFactoryTest::providerName() const
-{
- return "qmlgeo.test.plugin";
-}
-
-QStringList QGeoServiceProviderFactoryTest::keys() const
-{
- return QStringList() << QLatin1String("qmlgeo.test.plugin");
-}
-
-int QGeoServiceProviderFactoryTest::providerVersion() const
-{
- return 3;
-}
-
QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine (
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error, QString * errorString ) const
@@ -100,5 +85,3 @@ QPlaceManagerEngine* QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
Q_UNUSED(errorString);
return new QPlaceManagerEngineTest(parameters);
}
-
-Q_EXPORT_PLUGIN2(qtgeoservices_qmltestplugin, QGeoServiceProviderFactoryTest)
diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
index d81137b8..7508e6d0 100644
--- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h
@@ -50,16 +50,14 @@ QT_USE_NAMESPACE
class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "geotestplugin.json")
+
public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QString providerName() const;
- int providerVersion() const;
- QStringList keys() const;
-
-
QGeoMappingManagerEngine* createMappingManagerEngine (
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error, QString * errorString ) const;
diff --git a/tests/auto/geotestplugin/qplacemanagerengine_test.h b/tests/auto/geotestplugin/qplacemanagerengine_test.h
index 9149e4c5..c04035e4 100644
--- a/tests/auto/geotestplugin/qplacemanagerengine_test.h
+++ b/tests/auto/geotestplugin/qplacemanagerengine_test.h
@@ -394,12 +394,6 @@ public:
}
}
- QPlaceManager::ManagerFeatures supportedFeatures() const {
- return QPlaceManager::SavePlaceFeature
- | QPlaceManager::SaveCategoryFeature
- | QPlaceManager::SearchSuggestionsFeature;
- }
-
QPlace compatiblePlace(const QPlace &original) const {
QPlace place;
place.setName(original.name());
diff --git a/tests/auto/placesplugin_unsupported/placesplugin.json b/tests/auto/placesplugin_unsupported/placesplugin.json
new file mode 100644
index 00000000..6749962a
--- /dev/null
+++ b/tests/auto/placesplugin_unsupported/placesplugin.json
@@ -0,0 +1,8 @@
+{
+ "Keys": ["test.places.unsupported"],
+ "Provider": "test.places.unsupported",
+ "Version": 1,
+ "Experimental": true,
+ "Features": [
+ ]
+}
diff --git a/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro b/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro
index 126e673e..5bbf6bc7 100644
--- a/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro
+++ b/tests/auto/placesplugin_unsupported/placesplugin_unsupported.pro
@@ -11,3 +11,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+
+OTHER_FILES += \
+ placesplugin.json
diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
index be33c6e9..ba4b6832 100644
--- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.cpp
@@ -52,21 +52,6 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
{
}
-QString QGeoServiceProviderFactoryTest::providerName() const
-{
- return "test.places.unsupported";
-}
-
-QStringList QGeoServiceProviderFactoryTest::keys() const
-{
- return QStringList() << QLatin1String("test.places.unsupported");
-}
-
-int QGeoServiceProviderFactoryTest::providerVersion() const
-{
- return 1;
-}
-
QPlaceManagerEngine *QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const
@@ -76,5 +61,3 @@ QPlaceManagerEngine *QGeoServiceProviderFactoryTest::createPlaceManagerEngine(
return new QPlaceManagerEngine(parameters);
}
-
-Q_EXPORT_PLUGIN2(qtgeoservices_placesplugin_unsupported, QGeoServiceProviderFactoryTest)
diff --git a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
index fb90fed5..6e7b0962 100644
--- a/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/placesplugin_unsupported/qgeoserviceproviderplugin_test.h
@@ -49,16 +49,14 @@ QT_USE_NAMESPACE
class QGeoServiceProviderFactoryTest : public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "placesplugin.json")
public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QString providerName() const;
- int providerVersion() const;
- QStringList keys() const;
-
QPlaceManagerEngine *createPlaceManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp
index 7a292bec..8e72064c 100644
--- a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp
+++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.cpp
@@ -76,22 +76,22 @@ void tst_QGeocodingManager::cleanup()
void tst_QGeocodingManager::loadGeocodingManager()
{
QStringList providers = QGeoServiceProvider::availableServiceProviders();
- QVERIFY(providers.contains("static.geocode.test.plugin"));
+ QVERIFY(providers.contains("geocode.test.plugin"));
- qgeoserviceprovider = new QGeoServiceProvider("static.geocode.test.plugin");
+ qgeoserviceprovider = new QGeoServiceProvider("geocode.test.plugin");
QVERIFY(qgeoserviceprovider);
+ QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NotSupportedError);
+
+ qgeoserviceprovider->setAllowExperimental(true);
QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NoError);
+ QCOMPARE(qgeoserviceprovider->geocodingFeatures(),
+ QGeoServiceProvider::OfflineGeocodingFeature
+ | QGeoServiceProvider::ReverseGeocodingFeature);
qgeocodingmanager = qgeoserviceprovider->geocodingManager();
QVERIFY(qgeocodingmanager);
}
-void tst_QGeocodingManager::supports()
-{
- QVERIFY(qgeocodingmanager->supportsGeocoding());
- QVERIFY(qgeocodingmanager->supportsReverseGeocoding());
-}
-
void tst_QGeocodingManager::locale()
{
QLocale *german = new QLocale (QLocale::German, QLocale::Germany);
@@ -112,13 +112,13 @@ void tst_QGeocodingManager::locale()
void tst_QGeocodingManager::name()
{
- QString name = "static.geocode.test.plugin";
+ QString name = "geocode.test.plugin";
QCOMPARE(qgeocodingmanager->managerName(),name);
}
void tst_QGeocodingManager::version()
{
- int version=3;
+ int version=100;
QCOMPARE(qgeocodingmanager->managerVersion(),version);
}
diff --git a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h
index 70156dc3..e006d7c9 100644
--- a/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h
+++ b/tests/auto/qgeocodingmanager/tst_qgeocodingmanager.h
@@ -67,7 +67,6 @@ private Q_SLOTS:
void cleanupTestCase();
void init();
void cleanup();
- void supports();
void locale();
void name();
void version();
diff --git a/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json b/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json
new file mode 100644
index 00000000..9ac93536
--- /dev/null
+++ b/tests/auto/qgeocodingmanagerplugins/geocoding_plugin.json
@@ -0,0 +1,10 @@
+{
+ "Keys": ["geocode.test.plugin"],
+ "Provider": "geocode.test.plugin",
+ "Version": 100,
+ "Experimental": true,
+ "Features": [
+ "OfflineGeocodingFeature",
+ "ReverseGeocodingFeature"
+ ]
+}
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
index 4c1a2e66..c502010f 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
+++ b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerengine_test.h
@@ -80,8 +80,6 @@ public:
{
Q_UNUSED(error)
Q_UNUSED(errorString)
- setSupportsGeocoding(true);
- setSupportsReverseGeocoding(true);
setLocale(QLocale(QLocale::German, QLocale::Germany));
}
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro
index 3c41a645..936eb2f2 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro
+++ b/tests/auto/qgeocodingmanagerplugins/qgeocodingmanagerplugins.pro
@@ -12,3 +12,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+
+OTHER_FILES += \
+ geocoding_plugin.json
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
index 8c787804..32c27ce4 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.cpp
@@ -52,25 +52,8 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
{
}
-QString QGeoServiceProviderFactoryTest::providerName() const
-{
- return "static.geocode.test.plugin";
-}
-
-QStringList QGeoServiceProviderFactoryTest::keys() const
-{
- return QStringList() << QLatin1String("static.geocode.test.plugin");
-}
-
-int QGeoServiceProviderFactoryTest::providerVersion() const
-{
- return 3;
-}
-
QGeocodingManagerEngine* QGeoServiceProviderFactoryTest::createGeocodingManagerEngine(const QMap<
QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeocodingManagerEngineTest(parameters, error, errorString);
}
-
-Q_EXPORT_PLUGIN2(qtgeoservices_staticgeocodingplugin, QGeoServiceProviderFactoryTest)
diff --git a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
index 713af50c..8c8d6b23 100644
--- a/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/qgeocodingmanagerplugins/qgeoserviceproviderplugin_test.h
@@ -50,15 +50,14 @@ QT_USE_NAMESPACE
class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "geocoding_plugin.json")
+
public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QString providerName() const;
- int providerVersion() const;
- QStringList keys() const;
-
QGeocodingManagerEngine* createGeocodingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
};
diff --git a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
index 5c08cf49..7044f7b5 100644
--- a/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
+++ b/tests/auto/qgeoroutingmanager/tst_qgeoroutingmanager.cpp
@@ -68,10 +68,18 @@ void tst_QGeoRoutingManager::cleanup()
void tst_QGeoRoutingManager::loadRoutingManager()
{
QStringList providers = QGeoServiceProvider::availableServiceProviders();
- QVERIFY(providers.contains("static.georoute.test.plugin"));
+ QVERIFY(providers.contains("georoute.test.plugin"));
- qgeoserviceprovider = new QGeoServiceProvider("static.georoute.test.plugin");
+ qgeoserviceprovider = new QGeoServiceProvider("georoute.test.plugin");
QVERIFY(qgeoserviceprovider);
+ QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NotSupportedError);
+ qgeoserviceprovider->setAllowExperimental(true);
+
+ QCOMPARE(qgeoserviceprovider->routingFeatures(),
+ QGeoServiceProvider::OfflineRoutingFeature
+ | QGeoServiceProvider::AlternativeRoutesFeature
+ | QGeoServiceProvider::RouteUpdatesFeature
+ | QGeoServiceProvider::ExcludeAreasRoutingFeature);
QCOMPARE(qgeoserviceprovider->error(), QGeoServiceProvider::NoError);
qgeoroutingmanager = qgeoserviceprovider->routingManager();
@@ -81,9 +89,6 @@ void tst_QGeoRoutingManager::loadRoutingManager()
void tst_QGeoRoutingManager::supports()
{
- QVERIFY(qgeoroutingmanager->supportsAlternativeRoutes());
- QVERIFY(qgeoroutingmanager->supportsRouteUpdates());
- QVERIFY(qgeoroutingmanager->supportsExcludeAreas());
QCOMPARE(qgeoroutingmanager->supportedTravelModes(),QGeoRouteRequest::PedestrianTravel);
QCOMPARE(qgeoroutingmanager->supportedFeatureTypes(),QGeoRouteRequest::TollFeature);
QCOMPARE(qgeoroutingmanager->supportedFeatureWeights(),QGeoRouteRequest::PreferFeatureWeight);
@@ -109,13 +114,13 @@ void tst_QGeoRoutingManager::locale()
void tst_QGeoRoutingManager::name()
{
- QString name = "static.georoute.test.plugin";
+ QString name = "georoute.test.plugin";
QCOMPARE(qgeoroutingmanager->managerName(), name);
}
void tst_QGeoRoutingManager::version()
{
- QCOMPARE(qgeoroutingmanager->managerVersion(), 2);
+ QCOMPARE(qgeoroutingmanager->managerVersion(), 100);
}
void tst_QGeoRoutingManager::calculate()
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
index 0736e3d1..6fd61132 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerengine_test.h
@@ -61,9 +61,6 @@ public:
{
Q_UNUSED(error)
Q_UNUSED(errorString)
- setSupportsRouteUpdates(true);
- setSupportsAlternativeRoutes(true);
- setSupportsExcludeAreas(true);
setSupportedTravelModes(QGeoRouteRequest::PedestrianTravel);
setSupportedFeatureTypes(QGeoRouteRequest::TollFeature);
setSupportedFeatureWeights(QGeoRouteRequest::PreferFeatureWeight);
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro
index c5a39d3e..e2a3f6c4 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoroutingmanagerplugins.pro
@@ -12,3 +12,6 @@ SOURCES += qgeoserviceproviderplugin_test.cpp
target.path += $$[QT_INSTALL_PLUGINS]/geoservices
INSTALLS += target
+
+OTHER_FILES += \
+ routing_plugin.json
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
index 01549e30..177a4e5d 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.cpp
@@ -52,25 +52,8 @@ QGeoServiceProviderFactoryTest::~QGeoServiceProviderFactoryTest()
{
}
-QString QGeoServiceProviderFactoryTest::providerName() const
-{
- return "static.georoute.test.plugin";
-}
-
-QStringList QGeoServiceProviderFactoryTest::keys() const
-{
- return QStringList() << QLatin1String("static.georoute.test.plugin");
-}
-
-int QGeoServiceProviderFactoryTest::providerVersion() const
-{
- return 2;
-}
-
QGeoRoutingManagerEngine* QGeoServiceProviderFactoryTest::createRoutingManagerEngine(const QMap<
QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
return new QGeoRoutingManagerEngineTest(parameters, error, errorString);
}
-
-Q_EXPORT_PLUGIN2(qtgeoservices_staticroutingplugin, QGeoServiceProviderFactoryTest)
diff --git a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
index 611ff702..e1c100ad 100644
--- a/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
+++ b/tests/auto/qgeoroutingmanagerplugins/qgeoserviceproviderplugin_test.h
@@ -50,15 +50,14 @@ QT_USE_NAMESPACE
class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory
{
Q_OBJECT
- Q_INTERFACES(QGeoServiceProviderFactory:QFactoryInterface)
+ Q_INTERFACES(QGeoServiceProviderFactory)
+ Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0"
+ FILE "routing_plugin.json")
+
public:
QGeoServiceProviderFactoryTest();
~QGeoServiceProviderFactoryTest();
- QString providerName() const;
- int providerVersion() const;
- QStringList keys() const;
-
QGeoRoutingManagerEngine* createRoutingManagerEngine(const QMap<QString, QVariant> &parameters,
QGeoServiceProvider::Error *error, QString *errorString) const;
diff --git a/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json b/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json
new file mode 100644
index 00000000..25905f60
--- /dev/null
+++ b/tests/auto/qgeoroutingmanagerplugins/routing_plugin.json
@@ -0,0 +1,12 @@
+{
+ "Keys": ["georoute.test.plugin"],
+ "Provider": "georoute.test.plugin",
+ "Version": 100,
+ "Experimental": true,
+ "Features": [
+ "OfflineRoutingFeature",
+ "RouteUpdatesFeature",
+ "AlternativeRoutesFeature",
+ "ExcludeAreasRoutingFeature"
+ ]
+}
diff --git a/tests/auto/qplacemanager/tst_qplacemanager.cpp b/tests/auto/qplacemanager/tst_qplacemanager.cpp
index abc62aa6..2f9b471b 100644
--- a/tests/auto/qplacemanager/tst_qplacemanager.cpp
+++ b/tests/auto/qplacemanager/tst_qplacemanager.cpp
@@ -91,6 +91,8 @@ void tst_QPlaceManager::initTestCase()
QVERIFY(providers.contains("qmlgeo.test.plugin"));
provider = new QGeoServiceProvider("qmlgeo.test.plugin");
+ QCOMPARE(provider->placesFeatures() & QGeoServiceProvider::OfflinePlacesFeature,
+ QGeoServiceProvider::OfflinePlacesFeature);
placeManager = provider->placeManager();
QVERIFY(placeManager);
}
@@ -98,7 +100,7 @@ void tst_QPlaceManager::initTestCase()
void tst_QPlaceManager::testMetadata()
{
QCOMPARE(placeManager->managerName(), QLatin1String("qmlgeo.test.plugin"));
- QCOMPARE(placeManager->managerVersion(), 3);
+ QCOMPARE(placeManager->managerVersion(), 100);
}
void tst_QPlaceManager::testLocales()
diff --git a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
index 62a44e64..8763a4dd 100644
--- a/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
+++ b/tests/auto/qplacemanager_jsondb/tst_qplacemanager_jsondb.cpp
@@ -1695,19 +1695,16 @@ void tst_QPlaceManagerJsonDb::unsupportedFunctions()
void tst_QPlaceManagerJsonDb::supportedFeatures()
{
- QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::SavePlaceFeature),
- QPlaceManager::SavePlaceFeature);
- QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::RemovePlaceFeature),
- QPlaceManager::RemovePlaceFeature);
- QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::SaveCategoryFeature),
- QPlaceManager::SaveCategoryFeature);
- QCOMPARE((placeManager->supportedFeatures() & QPlaceManager::RemoveCategoryFeature),
- QPlaceManager::RemoveCategoryFeature);
-
- QVERIFY((placeManager->supportedFeatures() & QPlaceManager::RecommendationsFeature) == 0);
- QVERIFY((placeManager->supportedFeatures() & QPlaceManager::SearchSuggestionsFeature) == 0);
- QVERIFY((placeManager->supportedFeatures() & QPlaceManager::CorrectionsFeature) == 0);
- QVERIFY((placeManager->supportedFeatures() & QPlaceManager::LocaleFeature) == 0);
+ QGeoServiceProvider::PlacesFeatures f = QGeoServiceProvider::NoPlacesFeatures;
+
+ f |= QGeoServiceProvider::OfflinePlacesFeature;
+ f |= QGeoServiceProvider::SavePlaceFeature;
+ f |= QGeoServiceProvider::RemovePlaceFeature;
+ f |= QGeoServiceProvider::SaveCategoryFeature;
+ f |= QGeoServiceProvider::RemoveCategoryFeature;
+ f |= QGeoServiceProvider::PlaceMatchingFeature;
+
+ QCOMPARE(provider->placesFeatures(), f);
}
void tst_QPlaceManagerJsonDb::categoryFunctions()
diff --git a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
index c7b12ad8..67cc30c0 100644
--- a/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
+++ b/tests/auto/qplacemanager_unsupported/tst_qplacemanager_unsupported.cpp
@@ -96,6 +96,11 @@ void tst_QPlaceManagerUnsupported::initTestCase()
QVERIFY(providers.contains("test.places.unsupported"));
m_provider = new QGeoServiceProvider("test.places.unsupported");
+ QVERIFY(m_provider);
+ QCOMPARE(m_provider->error(), QGeoServiceProvider::NotSupportedError);
+ m_provider->setAllowExperimental(true);
+ QCOMPARE(m_provider->error(), QGeoServiceProvider::NoError);
+
m_manager = m_provider->placeManager();
QVERIFY(m_manager);
}
@@ -109,7 +114,7 @@ void tst_QPlaceManagerUnsupported::testMetadata()
{
QCOMPARE(m_manager->managerName(), QLatin1String("test.places.unsupported"));
QCOMPARE(m_manager->managerVersion(), 1);
- QCOMPARE(m_manager->supportedFeatures(), QPlaceManager::NoFeatures);
+ QCOMPARE(m_provider->placesFeatures(), QGeoServiceProvider::NoPlacesFeatures);
}
void tst_QPlaceManagerUnsupported::testLocales()