summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-06-12 03:00:35 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-06-12 03:00:36 +0200
commit7a7d355ac603283d05610e584d7c923e1d4caae0 (patch)
tree2b1e0991391b4fea05c9830e3831712bc0d6d26e /src/plugins/geoservices
parentaff3782a97cb7b120b5586194acd1816c08abe79 (diff)
parent71bc98bf309ce433afb80344a7356e13b310c5c5 (diff)
downloadqtlocation-7a7d355ac603283d05610e584d7c923e1d4caae0.tar.gz
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Id27e5a31f3a72eac38b976d546a1f733226cd5ae
Diffstat (limited to 'src/plugins/geoservices')
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp56
1 files changed, 32 insertions, 24 deletions
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index 964f94f5..6c47d3ee 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -45,14 +45,14 @@
namespace {
-QString formatPropertyName(QString *name)
+QByteArray formatPropertyName(const QByteArray &name)
{
+ QString nameAsString = QString::fromLatin1(name);
static const QRegularExpression camelCaseRegex(QStringLiteral("([a-z0-9])([A-Z])"));
-
- return name->replace(camelCaseRegex, QStringLiteral("\\1-\\2")).toLower();
+ return nameAsString.replace(camelCaseRegex, QStringLiteral("\\1-\\2")).toLower().toLatin1();
}
-bool isImmutableProperty(const QString &name)
+bool isImmutableProperty(const QByteArray &name)
{
return name == QStringLiteral("type") || name == QStringLiteral("layer");
}
@@ -167,6 +167,16 @@ QMapbox::Feature featureFromMapItem(QDeclarativeGeoMapItemBase *item)
}
}
+QList<QByteArray> getAllPropertyNamesList(QObject *object)
+{
+ const QMetaObject *metaObject = object->metaObject();
+ QList<QByteArray> propertyNames(object->dynamicPropertyNames());
+ for (int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i) {
+ propertyNames.append(metaObject->property(i).name());
+ }
+ return propertyNames;
+}
+
} // namespace
@@ -261,22 +271,20 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fro
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
- // Offset objectName and type properties.
- for (int i = 2; i < param->metaObject()->propertyCount(); ++i) {
- QString name = param->metaObject()->property(i).name();
-
- if (isImmutableProperty(name))
+ QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
+ for (const QByteArray &propertyName : propertyNames) {
+ if (isImmutableProperty(propertyName))
continue;
auto layout = new QMapboxGLStyleSetLayoutProperty();
- layout->m_value = param->property(name.toLatin1());
+ 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(&name);
+ layout->m_property = formatPropertyName(propertyName);
changes << QSharedPointer<QMapboxGLStyleChange>(layout);
}
@@ -340,22 +348,20 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::from
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
- // Offset objectName and type properties.
- for (int i = 2; i < param->metaObject()->propertyCount(); ++i) {
- QString name = param->metaObject()->property(i).name();
-
- if (isImmutableProperty(name))
+ QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
+ for (const QByteArray &propertyName : propertyNames) {
+ if (isImmutableProperty(propertyName))
continue;
auto paint = new QMapboxGLStyleSetPaintProperty();
- paint->m_value = param->property(name.toLatin1());
+ 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(&name);
+ paint->m_property = formatPropertyName(propertyName);
changes << QSharedPointer<QMapboxGLStyleChange>(paint);
}
@@ -464,14 +470,16 @@ QSharedPointer<QMapboxGLStyleChange> QMapboxGLStyleAddLayer::fromMapParameter(QG
static const QStringList layerProperties = QStringList()
<< QStringLiteral("name") << QStringLiteral("layerType") << QStringLiteral("before");
- // Offset objectName and type properties.
- for (int i = 2; i < param->metaObject()->propertyCount(); ++i) {
- QString name = param->metaObject()->property(i).name();
- QVariant value = param->property(name.toLatin1());
+ QList<QByteArray> propertyNames = getAllPropertyNamesList(param);
+ for (const QByteArray &propertyName : propertyNames) {
+ if (isImmutableProperty(propertyName))
+ continue;
+
+ const QVariant value = param->property(propertyName);
- switch (layerProperties.indexOf(name)) {
+ switch (layerProperties.indexOf(propertyName)) {
case -1:
- layer->m_params[formatPropertyName(&name)] = value;
+ layer->m_params[formatPropertyName(propertyName)] = value;
break;
case 0: // name
layer->m_params[QStringLiteral("id")] = value;