diff options
author | Alex Wilson <alex.wilson@nokia.com> | 2012-02-28 13:05:02 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-05 04:22:24 +0100 |
commit | 0287bfee05840511c12100f06f9142e3e2b8f7d5 (patch) | |
tree | f5386e27a4b012877d37ab0b99dfc1d5a08705c5 /src | |
parent | c1d56bdae90f79d466769aa7a357d78a4f2ca6c7 (diff) | |
download | qtlocation-0287bfee05840511c12100f06f9142e3e2b8f7d5.tar.gz |
New plugin API changes, centralized geoservice feature detection
This change adapts geoservice plugins to use the new Qt5 plugin API,
performing boolean feature detection all through the JSON blobs
rather than methods on factories or managers.
As a result of this centralisation, it was also necessary to rework
the QML API for the Plugin element a little. Some additional changes
were made to the declarative places plugin to prevent it crashing
due to plugins becoming available later than they did previously.
Task-number: QTBUG-24331
Change-Id: I26149987344b67091480449103ab1712c869b2a5
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src')
47 files changed, 803 insertions, 632 deletions
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 ¶meterMap); 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> ¶meters) +QGeoServiceProvider::QGeoServiceProvider(const QString &providerName, const QMap<QString, QVariant> ¶meters, 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> ¶meters) +{ + 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> ¶meters) +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> ¶meters) { - 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> ¶meters = (QMap<QString,QVariant>())); + const QMap<QString,QVariant> ¶meters = (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> ¶meters); + 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> ¶meters); - + void loadMeta(); + void loadPlugin(const QMap<QString, QVariant> ¶meters); + 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> ¶meters, 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> ¶meters, 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> ¶meters, 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> ¶meters, 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> ¶meters, 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(); } |