summaryrefslogtreecommitdiff
path: root/src/imports
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-01 09:53:55 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-01 09:54:08 +0200
commit19642842cea91a4588828362eba023c5da5ab57b (patch)
tree10366b074ae32e280300eb5f6fbcd5111ad4c82b /src/imports
parent1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93 (diff)
parente7099f14c8faea4fb7c89877973b7cec75044cb3 (diff)
downloadqtlocation-19642842cea91a4588828362eba023c5da5ab57b.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I4f29307985225a723304783e00a6844a1b9ee825
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 75f81e1c..9b5c658f 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)
{
@@ -542,6 +579,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 31723490..d1d69656 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -173,6 +173,7 @@ private Q_SLOTS:
void mappingManagerInitialized();
void pluginReady();
void onMapChildrenChanged();
+ void onSupportedMapTypesChanged();
private:
void setupMapView(QDeclarativeGeoMapItemView *view);