summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-10-08 14:42:22 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-11-02 10:06:01 +0200
commit4cb1cbe5e0b8fab5a8145a00d6d79205148d8971 (patch)
treebf417bf03f8e2127436560f39d4bf3f8543c9fef /src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
parentc032c91ee9776568d5593a3619ce0ac355e3135e (diff)
downloadqtlocation-4cb1cbe5e0b8fab5a8145a00d6d79205148d8971.tar.gz
Remove parameterization functionality
The abstraction of plugin-specific parameters makes little sense if we don't want to provide a cross-backend API. So remove this for now. If in the future we want to attach meta-data or backend-specific properties to values or element types, then we might be able to use existing QVariantMap type properties (like QGeoRouteRequest's extraParameters, via QDeclarativeGeoRouteQuery::extraParameters), or register backend specific QML types that applications can opt in to use. This requires a bit of research and experimenting based on specific use cases. If we can't come up with anything better, then bringing back a, perhaps simplified, version of the infrastructure removed here will still be an option. Change-Id: If590a35f2ffb80b0c918d866e88913a9caf75d2b Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp')
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp219
1 files changed, 0 insertions, 219 deletions
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index c094d51b..97a4cf39 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -196,43 +196,6 @@ QList<QByteArray> getAllPropertyNamesList(QObject *object)
} // namespace
-// QMapboxGLStyleChange
-
-QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapParameter(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
- changes << QMapboxGLStyleSetPaintProperty::fromMapParameter(param);
- break;
- case 1: // layout
- changes << QMapboxGLStyleSetLayoutProperty::fromMapParameter(param);
- break;
- case 2: // filter
- changes << QMapboxGLStyleSetFilter::fromMapParameter(param);
- break;
- case 3: // layer
- changes << QMapboxGLStyleAddLayer::fromMapParameter(param);
- break;
- case 4: // source
- changes << QMapboxGLStyleAddSource::fromMapParameter(param);
- break;
- case 5: // image
- changes << QMapboxGLStyleAddImage::fromMapParameter(param);
- break;
- }
-
- return changes;
-}
-
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDeclarativeGeoMapItemBase *item, const QString &before)
{
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
@@ -258,35 +221,6 @@ 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;
@@ -306,33 +240,6 @@ void QMapboxGLStyleSetLayoutProperty::apply(QMapboxGL *map)
map->setLayoutProperty(m_layer, m_property, m_value);
}
-QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "layout");
-
- QList<QSharedPointer<QMapboxGLStyleChange>> changes;
-
- QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
- for (const QByteArray &propertyName : propertyNames) {
- if (isImmutableProperty(propertyName))
- continue;
-
- auto layout = new QMapboxGLStyleSetLayoutProperty();
-
- layout->m_value = param->property(propertyName);
- if (layout->m_value.canConvert<QJSValue>()) {
- layout->m_value = layout->m_value.value<QJSValue>().toVariant();
- }
-
- layout->m_layer = param->property("layer").toString();
- layout->m_property = formatPropertyName(propertyName);
-
- changes << QSharedPointer<QMapboxGLStyleChange>(layout);
- }
-
- return changes;
-}
-
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fromMapItem(QDeclarativeGeoMapItemBase *item)
{
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
@@ -383,33 +290,6 @@ void QMapboxGLStyleSetPaintProperty::apply(QMapboxGL *map)
map->setPaintProperty(m_layer, m_property, m_value);
}
-QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "paint");
-
- QList<QSharedPointer<QMapboxGLStyleChange>> changes;
-
- QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
- for (const QByteArray &propertyName : propertyNames) {
- if (isImmutableProperty(propertyName))
- continue;
-
- auto paint = new QMapboxGLStyleSetPaintProperty();
-
- paint->m_value = param->property(propertyName);
- if (paint->m_value.canConvert<QJSValue>()) {
- paint->m_value = paint->m_value.value<QJSValue>().toVariant();
- }
-
- paint->m_layer = param->property("layer").toString();
- paint->m_property = formatPropertyName(propertyName);
-
- changes << QSharedPointer<QMapboxGLStyleChange>(paint);
- }
-
- return changes;
-}
-
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::fromMapItem(QDeclarativeGeoMapItemBase *item)
{
switch (item->itemType()) {
@@ -502,41 +382,6 @@ void QMapboxGLStyleAddLayer::apply(QMapboxGL *map)
map->addLayer(m_params, m_before);
}
-QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "layer");
-
- auto layer = new QMapboxGLStyleAddLayer();
-
- static const QStringList layerProperties = QStringList()
- << QStringLiteral("name") << QStringLiteral("layerType") << QStringLiteral("before");
-
- QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
- for (const QByteArray &propertyName : propertyNames) {
- if (isImmutableProperty(propertyName))
- continue;
-
- const QVariant value = param->property(propertyName);
-
- switch (layerProperties.indexOf(propertyName)) {
- case -1:
- layer->m_params[formatPropertyName(propertyName)] = value;
- break;
- case 0: // name
- layer->m_params[QStringLiteral("id")] = value;
- break;
- case 1: // layerType
- layer->m_params[QStringLiteral("type")] = value;
- break;
- case 2: // before
- layer->m_before = value.toString();
- break;
- }
- }
-
- return QSharedPointer<QMapboxGLStyleChange>(layer);
-}
-
QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromFeature(const QMapbox::Feature &feature, const QString &before)
{
auto layer = new QMapboxGLStyleAddLayer();
@@ -580,47 +425,6 @@ void QMapboxGLStyleAddSource::apply(QMapboxGL *map)
map->updateSource(m_id, m_params);
}
-QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddSource::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "source");
-
- static const QStringList acceptedSourceTypes = QStringList()
- << QStringLiteral("vector") << QStringLiteral("raster") << QStringLiteral("raster-dem") << QStringLiteral("geojson") << QStringLiteral("image");
-
- QString sourceType = param->property("sourceType").toString();
-
- auto source = new QMapboxGLStyleAddSource();
- source->m_id = param->property("name").toString();
- source->m_params[QStringLiteral("type")] = sourceType;
-
- switch (acceptedSourceTypes.indexOf(sourceType)) {
- case -1:
- qWarning() << "Invalid value for property 'sourceType': " + sourceType;
- break;
- case 0: // vector
- case 1: // raster
- case 2: // raster-dem
- source->m_params[QStringLiteral("url")] = param->property("url");
- break;
- case 3: { // geojson
- auto data = param->property("data").toString();
- if (data.startsWith(':')) {
- QFile geojson(data);
- geojson.open(QIODevice::ReadOnly);
- source->m_params[QStringLiteral("data")] = geojson.readAll();
- } else {
- source->m_params[QStringLiteral("data")] = data.toUtf8();
- }
- } break;
- case 4: { // image
- source->m_params[QStringLiteral("url")] = param->property("url");
- source->m_params[QStringLiteral("coordinates")] = param->property("coordinates");
- } break;
- }
-
- return QSharedPointer<QMapboxGLStyleChange>(source);
-}
-
QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddSource::fromFeature(const QMapbox::Feature &feature)
{
auto source = new QMapboxGLStyleAddSource();
@@ -657,32 +461,9 @@ void QMapboxGLStyleSetFilter::apply(QMapboxGL *map)
map->setFilter(m_layer, m_filter);
}
-QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleSetFilter::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "filter");
-
- auto filter = new QMapboxGLStyleSetFilter();
- filter->m_layer = param->property("layer").toString();
- filter->m_filter = param->property("filter");
-
- return QSharedPointer<QMapboxGLStyleChange>(filter);
-}
-
-
// QMapboxGLStyleAddImage
void QMapboxGLStyleAddImage::apply(QMapboxGL *map)
{
map->addImage(m_name, m_sprite);
}
-
-QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddImage::fromMapParameter(QGeoMapParameter *param)
-{
- Q_ASSERT(param->type() == "image");
-
- auto image = new QMapboxGLStyleAddImage();
- image->m_name = param->property("name").toString();
- image->m_sprite = QImage(param->property("sprite").toString());
-
- return QSharedPointer<QMapboxGLStyleChange>(image);
-}