Commit 1ced79ad authored by Paolo Angelelli's avatar Paolo Angelelli
Browse files

QGeoServiceProviderFactory: Restore binary compatibility to Qt 5.10


Added a new QGeoServiceProviderFactoryV2 to load plugins offering
a navigation manager engine.

To be able to still load plugins compiled against Qt 5.10, both factories
are considered when loading plugins, using the pointer to the V2 only
when accessing the newly exposed functionality.

Change-Id: I8e5e868737c77142e77caaacef278686565928df
Reviewed-by: default avatarAlex Blasche <alexander.blasche@qt.io>
Showing with 51 additions and 8 deletions
......@@ -360,7 +360,9 @@ template <> QPlaceManagerEngine *createEngine<QPlaceManagerEngine>(QGeoServicePr
}
template <> QNavigationManagerEngine *createEngine<QNavigationManagerEngine>(QGeoServiceProviderPrivate *d_ptr)
{
return d_ptr->factory->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->placeError), &(d_ptr->placeErrorString));
if (!d_ptr->factoryV2)
return nullptr;
return d_ptr->factoryV2->createNavigationManagerEngine(d_ptr->cleanedParameterMap, &(d_ptr->placeError), &(d_ptr->placeErrorString));
}
/* Template for generating the code for each of the geocodingManager(),
......@@ -656,7 +658,7 @@ void QGeoServiceProviderPrivate::unload()
delete navigationManager;
navigationManager = nullptr;
factory = 0;
factory = factoryV2 = nullptr;
error = QGeoServiceProvider::NoError;
errorString = QLatin1String("");
metaData = QJsonObject();
......@@ -686,7 +688,7 @@ void QGeoServiceProviderPrivate::filterParameterMap()
void QGeoServiceProviderPrivate::loadMeta()
{
factory = 0;
factory = factoryV2 = nullptr;
metaData = QJsonObject();
metaData.insert(QStringLiteral("index"), -1);
error = QGeoServiceProvider::NotSupportedError;
......@@ -727,7 +729,7 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap &parameters)
if (int(metaData.value(QStringLiteral("index")).toDouble()) < 0) {
error = QGeoServiceProvider::NotSupportedError;
errorString = QString(QLatin1String("The geoservices provider is not supported."));
factory = 0;
factory = factoryV2 = nullptr;
return;
}
......@@ -737,7 +739,9 @@ void QGeoServiceProviderPrivate::loadPlugin(const QVariantMap &parameters)
int idx = int(metaData.value(QStringLiteral("index")).toDouble());
// load the actual plugin
factory = qobject_cast<QGeoServiceProviderFactory *>(loader()->instance(idx));
QObject *instance = loader()->instance(idx);
factory = qobject_cast<QGeoServiceProviderFactory *>(instance);
factoryV2 = qobject_cast<QGeoServiceProviderFactoryV2 *>(instance);
}
QHash<QString, QJsonObject> QGeoServiceProviderPrivate::plugins(bool reload)
......
......@@ -62,6 +62,7 @@ class QGeoRoutingManager;
class QGeoMappingManager;
class QGeoServiceProviderFactory;
class QGeoServiceProviderFactoryV2;
class QGeoServiceProviderPrivate
{
......@@ -82,6 +83,7 @@ public:
Flags features(const char *enumName);
QGeoServiceProviderFactory *factory;
QGeoServiceProviderFactoryV2 *factoryV2 = nullptr;
QJsonObject metaData;
QVariantMap parameterMap;
......
......@@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE
\inmodule QtLocation
\ingroup QtLocation-impl
\since 5.6
\deprecated
\brief The QGeoServiceProviderFactory class is a factory class used as the
plugin interface for services related to geographical information.
......@@ -52,6 +53,8 @@ QT_BEGIN_NAMESPACE
The other functions should be overridden if the plugin supports the
associated set of functionality.
\sa QGeoServiceProviderFactoryV2
*/
/*!
......@@ -160,6 +163,28 @@ QPlaceManagerEngine *QGeoServiceProviderFactory::createPlaceManagerEngine(const
return 0;
}
/*!
\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.
......@@ -173,7 +198,7 @@ QPlaceManagerEngine *QGeoServiceProviderFactory::createPlaceManagerEngine(const
The default implementation returns nullptr, which causes a
QGeoServiceProvider::NotSupportedError in QGeoServiceProvider.
*/
QNavigationManagerEngine *QGeoServiceProviderFactory::createNavigationManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
QNavigationManagerEngine *QGeoServiceProviderFactoryV2::createNavigationManagerEngine(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString) const
{
Q_UNUSED(parameters)
Q_UNUSED(error)
......
......@@ -62,13 +62,25 @@ public:
virtual QPlaceManagerEngine *createPlaceManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
};
Q_DECLARE_INTERFACE(QGeoServiceProviderFactory,
"org.qt-project.qt.geoservice.serviceproviderfactory/5.0")
class Q_LOCATION_EXPORT QGeoServiceProviderFactoryV2 : public QGeoServiceProviderFactory
{
public:
virtual ~QGeoServiceProviderFactoryV2() {}
virtual QNavigationManagerEngine *createNavigationManagerEngine(const QVariantMap &parameters,
QGeoServiceProvider::Error *error,
QString *errorString) const;
};
Q_DECLARE_INTERFACE(QGeoServiceProviderFactory,
"org.qt-project.qt.geoservice.serviceproviderfactory/5.0")
// 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")
QT_END_NAMESPACE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment