summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTadej Novak <tadej@tano.si>2020-11-02 11:59:21 +0100
committerIvan Solovev <ivan.solovev@qt.io>2021-03-25 11:08:40 +0100
commitb79a14b7a05f6ef80351ba74e0ef386e3231eaa7 (patch)
tree90eb9a0e9e3cc2d750d2aefeaec87811bedf2298
parent46343aacc7158bfbaf6e066409e618bf94d3accc (diff)
downloadqtlocation-b79a14b7a05f6ef80351ba74e0ef386e3231eaa7.tar.gz
Allow removal of layers and sources created using parameters in MapboxGL
[ChangeLog][MapboxGL] Sources and layers from parameters can be removed Task-number: QTBUG-91623 Change-Id: I08db3e02b123f3ffb16e09fb77070ad5b6dbb18a Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp5
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp29
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h1
3 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
index 9c088f2f..66763af3 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
@@ -193,6 +193,11 @@ void QGeoMapMapboxGLPrivate::removeParameter(QGeoMapParameter *param)
Q_Q(QGeoMapMapboxGL);
q->disconnect(param);
+
+ if (m_styleLoaded) {
+ m_styleChanges << QMapboxGLStyleChange::removeMapParameter(param);
+ emit q->sgNodeChanged();
+ }
}
QGeoMap::ItemTypes QGeoMapMapboxGLPrivate::supportedMapItemTypes() const
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index 6dc8ea70..483f8f6d 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -255,6 +255,35 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDe
return changes;
}
+QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::removeMapParameter(QGeoMapParameter *param)
+{
+ static const QStringList acceptedParameterTypes = QStringList()
+ << QStringLiteral("paint") << QStringLiteral("layout") << QStringLiteral("filter")
+ << QStringLiteral("layer") << QStringLiteral("source") << QStringLiteral("image");
+
+ QList<QSharedPointer<QMapboxGLStyleChange>> changes;
+
+ switch (acceptedParameterTypes.indexOf(param->type())) {
+ case -1:
+ qWarning() << "Invalid value for property 'type': " + param->type();
+ break;
+ case 0: // paint
+ case 1: // layout
+ case 2: // filter
+ break;
+ case 3: // layer
+ changes << QSharedPointer<QMapboxGLStyleChange>(new QMapboxGLStyleRemoveLayer(param->property("name").toString()));
+ break;
+ case 4: // source
+ changes << QSharedPointer<QMapboxGLStyleChange>(new QMapboxGLStyleRemoveSource(param->property("name").toString()));
+ break;
+ case 5: // image
+ break;
+ }
+
+ return changes;
+}
+
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::removeMapItem(QDeclarativeGeoMapItemBase *item)
{
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
index fd5b9af4..9a8f50ea 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
@@ -59,6 +59,7 @@ public:
static QList<QSharedPointer<QMapboxGLStyleChange>> addMapParameter(QGeoMapParameter *);
static QList<QSharedPointer<QMapboxGLStyleChange>> addMapItem(QDeclarativeGeoMapItemBase *, const QString &before);
+ static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapParameter(QGeoMapParameter *);
static QList<QSharedPointer<QMapboxGLStyleChange>> removeMapItem(QDeclarativeGeoMapItemBase *);
virtual void apply(QMapboxGL *map) = 0;