summaryrefslogtreecommitdiff
path: root/src/imports
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-02 10:09:58 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-02 10:09:58 +0200
commitd031c0f7b13bb07227210632f66adceef71dc5bb (patch)
tree1a26163a1929c467c2de002a009364434c918dff /src/imports
parent76e3fea9e77713860211c599b2a0aff3a72902c6 (diff)
parent19642842cea91a4588828362eba023c5da5ab57b (diff)
downloadqtlocation-d031c0f7b13bb07227210632f66adceef71dc5bb.tar.gz
Merge remote-tracking branch 'origin/5.7' into dev
Change-Id: I9bfe99e7e619cbf03cda73c3df4f2f51851474ae
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp38
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 5d209bd7..9bb8a17a 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -254,6 +254,43 @@ void QDeclarativeGeoMap::onMapChildrenChanged()
copyrights->setCopyrightsZ(maxChildZ + 1);
}
+static QDeclarativeGeoMapType *findMapType(const QList<QDeclarativeGeoMapType *> &types, const QGeoMapType &type)
+{
+ for (int i = 0; i < types.size(); ++i)
+ if (types[i]->mapType() == type)
+ return types[i];
+ return Q_NULLPTR;
+}
+
+void QDeclarativeGeoMap::onSupportedMapTypesChanged()
+{
+ QList<QDeclarativeGeoMapType *> supportedMapTypes;
+ QList<QGeoMapType> types = m_mappingManager->supportedMapTypes();
+ for (int i = 0; i < types.size(); ++i) {
+ // types that are present and get removed will be deleted at QObject destruction
+ QDeclarativeGeoMapType *type = findMapType(m_supportedMapTypes, types[i]);
+ if (!type)
+ type = new QDeclarativeGeoMapType(types[i], this);
+ supportedMapTypes.append(type);
+ }
+ m_supportedMapTypes.swap(supportedMapTypes);
+ if (m_supportedMapTypes.isEmpty()) {
+ m_map->setActiveMapType(QGeoMapType()); // no supported map types: setting an invalid one
+ } else {
+ bool hasMapType = false;
+ foreach (QDeclarativeGeoMapType *declarativeType, m_supportedMapTypes) {
+ if (declarativeType->mapType() == m_map->activeMapType())
+ hasMapType = true;
+ }
+ if (!hasMapType) {
+ QDeclarativeGeoMapType *type = m_supportedMapTypes.at(0);
+ m_activeMapType = type;
+ m_map->setActiveMapType(type->mapType());
+ }
+ }
+
+ emit supportedMapTypesChanged();
+}
void QDeclarativeGeoMap::setError(QGeoServiceProvider::Error error, const QString &errorString)
{
@@ -541,6 +578,7 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
// This prefetches a buffer around the map
m_map->prefetchData();
+ connect(m_mappingManager, SIGNAL(supportedMapTypesChanged()), this, SLOT(onSupportedMapTypesChanged()));
emit minimumZoomLevelChanged();
emit maximumZoomLevelChanged();
emit supportedMapTypesChanged();
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index cef1b157..262314ed 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -172,6 +172,7 @@ private Q_SLOTS:
void mappingManagerInitialized();
void pluginReady();
void onMapChildrenChanged();
+ void onSupportedMapTypesChanged();
private:
void setupMapView(QDeclarativeGeoMapItemView *view);