summaryrefslogtreecommitdiffstats
path: root/src/location
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-04-12 15:21:03 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-07 07:02:12 +0000
commit1c29e3f36976134d1db3133d49ee3dc21eb1c07a (patch)
treedccc569a84a69fc6540b0a2fb27b19a0b4f75372 /src/location
parentacb1f42d21b94c4c783433c2e7d67646c905afb7 (diff)
Add pluginName to QGeoMapType and check against it in setActiveMapType
This patch adds a QByteArray member to QGeoMapType with the name of the plugin providing that map type. This value is then used to validate what is passed to QDeclarativeGeoMap::setActiveMapType to see if it's a map type for the currently set plugin. Change-Id: If15b67c32150f0c3c2815d28e26fc37138d4cf71 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location')
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp34
-rw-r--r--src/location/maps/qgeomaptype.cpp20
-rw-r--r--src/location/maps/qgeomaptype_p.h3
-rw-r--r--src/location/maps/qgeomaptype_p_p.h5
4 files changed, 43 insertions, 19 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 9e679afb..2c699aa6 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -190,7 +190,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
tr("No Map"),
- tr("No Map"), false, false, 0), this);
+ tr("No Map"), false, false, 0, QByteArrayLiteral("")), this);
m_cameraData.setCenter(QGeoCoordinate(51.5073,-0.1277)); //London city center
m_cameraData.setZoomLevel(8.0);
@@ -738,12 +738,20 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
m_supportedMapTypes.append(type);
}
- if (!m_supportedMapTypes.isEmpty()) {
- QDeclarativeGeoMapType *type = m_supportedMapTypes.at(0);
- m_activeMapType = type;
- m_map->setActiveMapType(type->mapType());
- } else {
+ if (m_activeMapType && m_plugin->name().toLatin1() == m_activeMapType->mapType().pluginName()) {
m_map->setActiveMapType(m_activeMapType->mapType());
+ } else {
+ if (m_activeMapType)
+ m_activeMapType->deleteLater();
+
+ if (!m_supportedMapTypes.isEmpty()) {
+ m_activeMapType = m_supportedMapTypes.at(0);
+ m_map->setActiveMapType(m_activeMapType->mapType());
+ } else {
+ m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
+ tr("No Map"),
+ tr("No Map"), false, false, 0, QByteArrayLiteral("")), this);
+ }
}
// Update camera capabilities
@@ -1890,10 +1898,16 @@ void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGro
void QDeclarativeGeoMap::setActiveMapType(QDeclarativeGeoMapType *mapType)
{
if (m_activeMapType->mapType() != mapType->mapType()) {
- m_activeMapType = mapType;
- if (m_map)
- m_map->setActiveMapType(mapType->mapType());
- emit activeMapTypeChanged();
+ if (m_map) {
+ if (mapType->mapType().pluginName() == m_plugin->name().toLatin1()) {
+ m_map->setActiveMapType(mapType->mapType());
+ m_activeMapType = mapType;
+ emit activeMapTypeChanged();
+ }
+ } else {
+ m_activeMapType = mapType;
+ emit activeMapTypeChanged();
+ }
}
}
diff --git a/src/location/maps/qgeomaptype.cpp b/src/location/maps/qgeomaptype.cpp
index b4efa1d9..34781451 100644
--- a/src/location/maps/qgeomaptype.cpp
+++ b/src/location/maps/qgeomaptype.cpp
@@ -46,8 +46,8 @@ QGeoMapType::QGeoMapType(const QGeoMapType &other)
: d_ptr(other.d_ptr) {}
QGeoMapType::QGeoMapType(QGeoMapType::MapStyle style, const QString &name,
- const QString &description, bool mobile, bool night, int mapId)
-: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId))
+ const QString &description, bool mobile, bool night, int mapId, QByteArray pluginName)
+: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId, pluginName))
{
}
@@ -102,6 +102,11 @@ int QGeoMapType::mapId() const
return d_ptr->mapId_;
}
+QByteArray QGeoMapType::pluginName() const
+{
+ return d_ptr->pluginName_;
+}
+
QGeoMapTypePrivate::QGeoMapTypePrivate()
: style_(QGeoMapType::NoMap), mobile_(false), night_(false), mapId_(0)
{
@@ -109,15 +114,15 @@ QGeoMapTypePrivate::QGeoMapTypePrivate()
QGeoMapTypePrivate::QGeoMapTypePrivate(const QGeoMapTypePrivate &other)
: QSharedData(other), style_(other.style_), name_(other.name_), description_(other.description_),
- mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_)
+ mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_), pluginName_(other.pluginName_)
{
}
QGeoMapTypePrivate::QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name,
const QString &description, bool mobile, bool night,
- int mapId)
+ int mapId, QByteArray pluginName)
: style_(style), name_(name), description_(description), mobile_(mobile), night_(night),
- mapId_(mapId)
+ mapId_(mapId), pluginName_(pluginName)
{
}
@@ -127,8 +132,9 @@ QGeoMapTypePrivate::~QGeoMapTypePrivate()
bool QGeoMapTypePrivate::operator==(const QGeoMapTypePrivate &other) const
{
- return style_ == other.style_ && name_ == other.name_ && description_ == other.description_ &&
- mobile_ == other.mobile_ && night_ == other.night_ && mapId_ == other.mapId_;
+ return pluginName_ == other.pluginName_ && style_ == other.style_ && name_ == other.name_ &&
+ description_ == other.description_ && mobile_ == other.mobile_ && night_ == other.night_ &&
+ mapId_ == other.mapId_;
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h
index f26471f4..4b5cb0d0 100644
--- a/src/location/maps/qgeomaptype_p.h
+++ b/src/location/maps/qgeomaptype_p.h
@@ -77,7 +77,7 @@ public:
QGeoMapType();
QGeoMapType(const QGeoMapType &other);
QGeoMapType(MapStyle style, const QString &name, const QString &description, bool mobile,
- bool night, int mapId);
+ bool night, int mapId, QByteArray pluginName);
~QGeoMapType();
QGeoMapType &operator = (const QGeoMapType &other);
@@ -91,6 +91,7 @@ public:
bool mobile() const;
bool night() const;
int mapId() const;
+ QByteArray pluginName() const;
private:
QSharedDataPointer<QGeoMapTypePrivate> d_ptr;
diff --git a/src/location/maps/qgeomaptype_p_p.h b/src/location/maps/qgeomaptype_p_p.h
index 2aafd37b..039c0962 100644
--- a/src/location/maps/qgeomaptype_p_p.h
+++ b/src/location/maps/qgeomaptype_p_p.h
@@ -50,6 +50,7 @@
#include <QMetaType>
#include <QString>
+#include <QByteArray>
#include <QSharedData>
#include "qgeomaptype_p.h"
@@ -60,7 +61,8 @@ class QGeoMapTypePrivate : public QSharedData
{
public:
QGeoMapTypePrivate();
- QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, bool night, int mapId);
+ QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile,
+ bool night, int mapId, QByteArray pluginName);
QGeoMapTypePrivate(const QGeoMapTypePrivate &other);
~QGeoMapTypePrivate();
@@ -74,6 +76,7 @@ public:
bool mobile_;
bool night_;
int mapId_;
+ QByteArray pluginName_;
};
QT_END_NAMESPACE