diff options
-rw-r--r-- | src/location/maps/qgeoserviceprovider.cpp | 28 | ||||
-rw-r--r-- | src/location/maps/qgeoserviceprovider_p.h | 6 | ||||
-rw-r--r-- | src/location/maps/qgeoserviceproviderfactory.cpp | 103 | ||||
-rw-r--r-- | src/location/maps/qgeoserviceproviderfactory.h | 29 | ||||
-rw-r--r-- | tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h | 6 |
5 files changed, 57 insertions, 115 deletions
diff --git a/src/location/maps/qgeoserviceprovider.cpp b/src/location/maps/qgeoserviceprovider.cpp index 63ec92c8..f0fcf332 100644 --- a/src/location/maps/qgeoserviceprovider.cpp +++ b/src/location/maps/qgeoserviceprovider.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtLocation module of the Qt Toolkit. @@ -365,9 +365,7 @@ template <> QPlaceManagerEngine *createEngine<QPlaceManagerEngine>(QGeoServicePr } template <> QNavigationManagerEngine *createEngine<QNavigationManagerEngine>(QGeoServiceProviderPrivate *d_ptr) { - if (!d_ptr->factoryV2) - return nullptr; - return d_ptr->factoryV2->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->navigationError), &(d_ptr->navigationErrorString)); + return d_ptr->factory->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->navigationError), &(d_ptr->navigationErrorString)); } /* Template for generating the code for each of the geocodingManager(), @@ -799,7 +797,7 @@ void QGeoServiceProviderPrivate::unload() delete navigationManager; navigationManager = nullptr; - factory = factoryV2 = factoryV3 = nullptr; + factory = nullptr; error = QGeoServiceProvider::NoError; errorString = QLatin1String(""); metaData = QJsonObject(); @@ -829,7 +827,7 @@ void QGeoServiceProviderPrivate::filterParameterMap() void QGeoServiceProviderPrivate::loadMeta() { - factory = factoryV2 = factoryV3 = nullptr; + factory = nullptr; metaData = QJsonObject(); metaData.insert(QStringLiteral("index"), -1); error = QGeoServiceProvider::NotSupportedError; @@ -870,7 +868,7 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap ¶meters) if (int(metaData.value(QStringLiteral("index")).toDouble()) < 0) { error = QGeoServiceProvider::NotSupportedError; errorString = QString(QLatin1String("The geoservices provider is not supported.")); - factory = factoryV2 = factoryV3 = nullptr; + factory = nullptr; return; } @@ -880,23 +878,13 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap ¶meters) int idx = int(metaData.value(QStringLiteral("index")).toDouble()); // load the actual plugin - QObject *instance = loader()->instance(idx); - if (!instance) { + factory = qobject_cast<QGeoServiceProviderFactory *>(loader()->instance(idx)); + if (!factory) { error = QGeoServiceProvider::LoaderError; errorString = QLatin1String("loader()->instance(idx) failed to return an instance. Set the environment variable QT_DEBUG_PLUGINS to see more details."); return; } - factoryV3 = qobject_cast<QGeoServiceProviderFactoryV3 *>(instance); - if (!factoryV3) { - factoryV2 = qobject_cast<QGeoServiceProviderFactoryV2 *>(instance); - if (!factoryV2) - factory = qobject_cast<QGeoServiceProviderFactory *>(instance); - else - factory = factoryV2; - } else { - factory = factoryV2 = factoryV3; - factoryV3->setQmlEngine(qmlEngine); - } + factory->setQmlEngine(qmlEngine); } QMultiHash<QString, QJsonObject> QGeoServiceProviderPrivate::plugins(bool reload) diff --git a/src/location/maps/qgeoserviceprovider_p.h b/src/location/maps/qgeoserviceprovider_p.h index bbce84e7..cd7dbf73 100644 --- a/src/location/maps/qgeoserviceprovider_p.h +++ b/src/location/maps/qgeoserviceprovider_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtLocation module of the Qt Toolkit. @@ -66,8 +66,6 @@ class QGeoRoutingManager; class QGeoMappingManager; class QGeoServiceProviderFactory; -class QGeoServiceProviderFactoryV2; -class QGeoServiceProviderFactoryV3; class QQmlEngine; class QGeoServiceProviderPrivate @@ -89,8 +87,6 @@ public: Flags features(const char *enumName) const; QGeoServiceProviderFactory *factory; - QGeoServiceProviderFactoryV2 *factoryV2 = nullptr; - QGeoServiceProviderFactoryV3 *factoryV3 = nullptr; QJsonObject metaData; QVariantMap parameterMap; diff --git a/src/location/maps/qgeoserviceproviderfactory.cpp b/src/location/maps/qgeoserviceproviderfactory.cpp index 39655ace..fd34047a 100644 --- a/src/location/maps/qgeoserviceproviderfactory.cpp +++ b/src/location/maps/qgeoserviceproviderfactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtLocation module of the Qt Toolkit. @@ -56,32 +56,31 @@ QT_BEGIN_NAMESPACE The other functions should be overridden if the plugin supports the associated set of functionality. - - \sa QGeoServiceProviderFactoryV2 */ /*! -\fn QGeoServiceProviderFactory::~QGeoServiceProviderFactory() + \fn QGeoServiceProviderFactory::~QGeoServiceProviderFactory() -Destroys this QGeoServiceProviderFactory instance. + Destroys this QGeoServiceProviderFactory instance. */ /*! Returns a new QGeoCodingManagerEngine instance, initialized with \a parameters, which implements the location geocoding functionality. - If \a error is not 0 it should be set to QGeoServiceProvider::NoError on + If \a error is not \nullptr it should be set to QGeoServiceProvider::NoError on success or an appropriate QGeoServiceProvider::Error on failure. - If \a errorString is not 0 it should be set to a string describing any + If \a errorString is not \nullptr it should be set to a string describing any error which occurred. - The default implementation returns 0, which causes a + The default implementation returns \nullptr, which causes a QGeoServiceProvider::NotSupportedError in QGeoServiceProvider. */ -QGeoCodingManagerEngine *QGeoServiceProviderFactory::createGeocodingManagerEngine(const QVariantMap ¶meters, - QGeoServiceProvider::Error *error, - QString *errorString) const +QGeoCodingManagerEngine * +QGeoServiceProviderFactory::createGeocodingManagerEngine(const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) const { Q_UNUSED(parameters); Q_UNUSED(error); @@ -94,20 +93,21 @@ QGeoCodingManagerEngine *QGeoServiceProviderFactory::createGeocodingManagerEngin Returns a new QGeoMappingManagerEngine instance, initialized with \a parameters, which implements mapping functionality. - If \a error is not 0 it should be set to QGeoServiceProvider::NoError on + If \a error is not \nullptr it should be set to QGeoServiceProvider::NoError on success or an appropriate QGeoServiceProvider::Error on failure. - If \a errorString is not 0 it should be set to a string describing any + If \a errorString is not \nullptr it should be set to a string describing any error which occurred. - The default implementation returns 0, which causes a + The default implementation returns \nullptr, which causes a QGeoServiceProvider::NotSupportedError in QGeoServiceProvider. \internal */ -QGeoMappingManagerEngine *QGeoServiceProviderFactory::createMappingManagerEngine(const QVariantMap ¶meters, - QGeoServiceProvider::Error *error, - QString *errorString) const +QGeoMappingManagerEngine * +QGeoServiceProviderFactory::createMappingManagerEngine(const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) const { Q_UNUSED(parameters); Q_UNUSED(error); @@ -120,94 +120,76 @@ QGeoMappingManagerEngine *QGeoServiceProviderFactory::createMappingManagerEngine Returns a new QGeoRoutingManagerEngine instance, initialized with \a parameters, which implements routing functionality. - If \a error is not 0 it should be set to QGeoServiceProvider::NoError on + If \a error is not \nullptr it should be set to QGeoServiceProvider::NoError on success or an appropriate QGeoServiceProvider::Error on failure. - If \a errorString is not 0 it should be set to a string describing any + If \a errorString is not \nullptr it should be set to a string describing any error which occurred. - The default implementation returns 0, which causes a + The default implementation returns \nullptr, which causes a QGeoServiceProvider::NotSupportedError in QGeoServiceProvider. */ -QGeoRoutingManagerEngine *QGeoServiceProviderFactory::createRoutingManagerEngine(const QVariantMap ¶meters, - QGeoServiceProvider::Error *error, - QString *errorString) const +QGeoRoutingManagerEngine * +QGeoServiceProviderFactory::createRoutingManagerEngine(const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) const { Q_UNUSED(parameters); Q_UNUSED(error); Q_UNUSED(errorString); - return 0; + return nullptr; } /*! Returns a new QPlaceManagerEngine instance, initialized with \a parameters, which implements the place searching functionality. - If \a error is not 0 it should be set to QGeoServiceProvider::NoError on + If \a error is not \nullptr it should be set to QGeoServiceProvider::NoError on success or an appropriate QGeoServiceProvider::Error on failure. - If \a errorString is not 0 it should be set to a string describing any + If \a errorString is not \nullptr it should be set to a string describing any error which occurred. - The default implementation returns 0, which causes a + The default implementation returns \nullptr, which causes a QGeoServiceProvider::NotSupportedError in QGeoServiceProvider. */ -QPlaceManagerEngine *QGeoServiceProviderFactory::createPlaceManagerEngine(const QVariantMap ¶meters, - QGeoServiceProvider::Error *error, - QString *errorString) const - +QPlaceManagerEngine * +QGeoServiceProviderFactory::createPlaceManagerEngine(const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) const { Q_UNUSED(parameters); Q_UNUSED(error); Q_UNUSED(errorString); - return 0; + return nullptr; } /*! - \class QGeoServiceProviderFactoryV2 - \inmodule QtLocation - \ingroup QtLocation-impl - \since 5.11 - - \brief The QGeoServiceProviderFactoryV2 class is a factory class used as the - plugin interface for services related to geographical information. - - Implementers must provide a unique combination of providerName() and - providerVersion() per plugin. - - The other functions should be overridden if the plugin supports the - associated set of functionality. -*/ - -/*! -\fn QGeoServiceProviderFactoryV2::~QGeoServiceProviderFactoryV2() - -Destroys this QGeoServiceProviderFactoryV2 instance. -*/ - -/*! Returns a new QNavigationManagerEngine instance, initialized with \a parameters, which implements navigation functionality. - If \a error is not nullptr, it should be set to QGeoServiceProvider::NoError on + If \a error is not \nullptr, it should be set to QGeoServiceProvider::NoError on success or an appropriate QGeoServiceProvider::Error on failure. - If \a errorString is not nullptr, it should be set to a string describing any + If \a errorString is not \nullptr, it should be set to a string describing any error which occurred. - The default implementation returns nullptr, which causes a + The default implementation returns \nullptr, which causes a QGeoServiceProvider::NotSupportedError in QGeoServiceProvider. */ -QNavigationManagerEngine *QGeoServiceProviderFactoryV2::createNavigationManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const +QNavigationManagerEngine * +QGeoServiceProviderFactory::createNavigationManagerEngine(const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) const { Q_UNUSED(parameters); Q_UNUSED(error); Q_UNUSED(errorString); - return 0; + return nullptr; } /*! @@ -217,10 +199,9 @@ QNavigationManagerEngine *QGeoServiceProviderFactoryV2::createNavigationManagerE The default implementation does nothing. \since 5.12 */ -void QGeoServiceProviderFactoryV3::setQmlEngine(QQmlEngine *engine) +void QGeoServiceProviderFactory::setQmlEngine(QQmlEngine *engine) { Q_UNUSED(engine); } QT_END_NAMESPACE - diff --git a/src/location/maps/qgeoserviceproviderfactory.h b/src/location/maps/qgeoserviceproviderfactory.h index 187476dc..f804cbe6 100644 --- a/src/location/maps/qgeoserviceproviderfactory.h +++ b/src/location/maps/qgeoserviceproviderfactory.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtLocation module of the Qt Toolkit. @@ -66,38 +66,15 @@ public: virtual QPlaceManagerEngine *createPlaceManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; -}; - -Q_DECLARE_INTERFACE(QGeoServiceProviderFactory, - "org.qt-project.qt.geoservice.serviceproviderfactory/6.0") - -class Q_LOCATION_EXPORT QGeoServiceProviderFactoryV2 : public QGeoServiceProviderFactory -{ -public: - virtual ~QGeoServiceProviderFactoryV2() {} virtual QNavigationManagerEngine *createNavigationManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; -}; - -// Although not actually used for constructing a specialized loader, this is required for -// casting a QObject * into QGeoServiceProviderFactoryV2 * -Q_DECLARE_INTERFACE(QGeoServiceProviderFactoryV2, - "org.qt-project.qt.geoservice.serviceproviderfactoryV2/5.0") - -class Q_LOCATION_EXPORT QGeoServiceProviderFactoryV3 : public QGeoServiceProviderFactoryV2 -{ -public: - virtual ~QGeoServiceProviderFactoryV3() {} - virtual void setQmlEngine(QQmlEngine * engine); }; -// Although not actually used for constructing a specialized loader, this is required for -// casting a QObject * into QGeoServiceProviderFactoryV3 * -Q_DECLARE_INTERFACE(QGeoServiceProviderFactoryV3, - "org.qt-project.qt.geoservice.serviceproviderfactoryV3/5.0") +Q_DECLARE_INTERFACE(QGeoServiceProviderFactory, + "org.qt-project.qt.geoservice.serviceproviderfactory/6.0") QT_END_NAMESPACE diff --git a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h index 01a422c1..841d0341 100644 --- a/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h +++ b/tests/auto/geotestplugin/qgeoserviceproviderplugin_test.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -34,10 +34,10 @@ QT_USE_NAMESPACE -class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactoryV2 +class QGeoServiceProviderFactoryTest: public QObject, public QGeoServiceProviderFactory { Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactoryV2) + Q_INTERFACES(QGeoServiceProviderFactory) Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/6.0" FILE "geotestplugin.json") |