summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-08-02 15:51:16 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-08-17 14:43:22 +0300
commit5057d7ef5d218f3f9636d128e36970c077acafbd (patch)
tree59d58ab3a4a50e5116ea8a7243f54674a8ca7f30 /platform
parentaa13acdb8782f3f2b671080342644ad6b8561973 (diff)
downloadqtlocation-mapboxgl-5057d7ef5d218f3f9636d128e36970c077acafbd.tar.gz
[Qt] Use QVariantMap in QQuickMapboxGLStyleProperty
Diffstat (limited to 'platform')
-rw-r--r--platform/qt/include/qquickmapboxgl.hpp24
-rw-r--r--platform/qt/include/qquickmapboxglstyleproperty.hpp7
-rw-r--r--platform/qt/src/qquickmapboxgl.cpp19
-rw-r--r--platform/qt/src/qquickmapboxglrenderer.cpp4
-rw-r--r--platform/qt/src/qquickmapboxglstyleproperty.cpp32
5 files changed, 29 insertions, 57 deletions
diff --git a/platform/qt/include/qquickmapboxgl.hpp b/platform/qt/include/qquickmapboxgl.hpp
index c651afef00..325a5f99dd 100644
--- a/platform/qt/include/qquickmapboxgl.hpp
+++ b/platform/qt/include/qquickmapboxgl.hpp
@@ -34,19 +34,6 @@ class Q_DECL_EXPORT QQuickMapboxGL : public QQuickFramebufferObject
Q_PROPERTY(qreal pitch READ pitch WRITE setPitch NOTIFY pitchChanged)
public:
- struct LayoutPropertyChange {
- QString layer;
- QString property;
- QVariant value;
- };
-
- struct PaintPropertyChange {
- QString layer;
- QString property;
- QVariant value;
- QString klass;
- };
-
QQuickMapboxGL(QQuickItem *parent = 0);
virtual ~QQuickMapboxGL();
@@ -82,8 +69,8 @@ public:
Q_INVOKABLE void pan(int dx, int dy);
- QList<LayoutPropertyChange>& layoutPropertyChanges() { return m_layoutChanges; }
- QList<PaintPropertyChange>& paintPropertyChanges() { return m_paintChanges; }
+ QList<QVariantMap>& layoutPropertyChanges() { return m_layoutChanges; }
+ QList<QVariantMap>& paintPropertyChanges() { return m_paintChanges; }
// MapboxGL QML Type interface.
void setStyle(const QString &style);
@@ -97,9 +84,6 @@ public:
QPointF swapPan();
- void setLayoutProperty(const QString &layer, const QString &property, const QVariant &value);
- void setPaintProperty(const QString &layer, const QString &property, const QVariant &value, const QString &klass = QString());
-
enum SyncState {
NothingNeedsSync = 0,
ZoomNeedsSync = 1 << 0,
@@ -142,8 +126,8 @@ private:
QGeoCoordinate m_center;
QGeoShape m_visibleRegion;
QColor m_color;
- QList<LayoutPropertyChange> m_layoutChanges;
- QList<PaintPropertyChange> m_paintChanges;
+ QList<QVariantMap> m_layoutChanges;
+ QList<QVariantMap> m_paintChanges;
QString m_style;
qreal m_bearing = 0;
diff --git a/platform/qt/include/qquickmapboxglstyleproperty.hpp b/platform/qt/include/qquickmapboxglstyleproperty.hpp
index 99832eed85..f7762b4ee6 100644
--- a/platform/qt/include/qquickmapboxglstyleproperty.hpp
+++ b/platform/qt/include/qquickmapboxglstyleproperty.hpp
@@ -35,9 +35,7 @@ protected:
QQuickMapboxGLStyleProperty(QQuickItem *parent);
virtual void updateParent() = 0;
- QVariant m_layer;
- QVariant m_property;
- QVariant m_value;
+ QVariantMap m_map;
};
class Q_DECL_EXPORT QQuickMapboxGLLayoutStyleProperty : public QQuickMapboxGLStyleProperty
@@ -67,9 +65,6 @@ signals:
protected:
virtual void updateParent();
-
-private:
- QVariant m_class;
};
#endif // QQUICKMAPBOXGLSTYLEPROPERTY_H
diff --git a/platform/qt/src/qquickmapboxgl.cpp b/platform/qt/src/qquickmapboxgl.cpp
index d8492c5218..9e90593bbd 100644
--- a/platform/qt/src/qquickmapboxgl.cpp
+++ b/platform/qt/src/qquickmapboxgl.cpp
@@ -156,7 +156,12 @@ void QQuickMapboxGL::setColor(const QColor &color)
m_color = color;
- setPaintProperty("background", "background-color", color);
+ QVariantMap paintProperty;
+ paintProperty["type"] = QQuickMapboxGLLayoutStyleProperty::PaintType;
+ paintProperty["layer"] = "background";
+ paintProperty["property"] = "background-color";
+ paintProperty["value"] = color;
+ onStylePropertyUpdated(paintProperty);
emit colorChanged(m_color);
}
@@ -174,18 +179,6 @@ void QQuickMapboxGL::pan(int dx, int dy)
update();
}
-void QQuickMapboxGL::setLayoutProperty(const QString &layer, const QString &property, const QVariant &value)
-{
- m_layoutChanges.append(LayoutPropertyChange { layer, property, value });
- update();
-}
-
-void QQuickMapboxGL::setPaintProperty(const QString &layer, const QString &property, const QVariant &value, const QString &klass)
-{
- m_paintChanges.append(PaintPropertyChange { layer, property, value, klass });
- update();
-}
-
void QQuickMapboxGL::setStyle(const QString &styleUrl)
{
if (m_style == styleUrl) {
diff --git a/platform/qt/src/qquickmapboxglrenderer.cpp b/platform/qt/src/qquickmapboxglrenderer.cpp
index 326eafa928..35a32be2ad 100644
--- a/platform/qt/src/qquickmapboxglrenderer.cpp
+++ b/platform/qt/src/qquickmapboxglrenderer.cpp
@@ -89,14 +89,14 @@ void QQuickMapboxGLRenderer::synchronize(QQuickFramebufferObject *item)
if (m_styleLoaded) {
if (!quickMap->layoutPropertyChanges().empty()) {
for (const auto& change: quickMap->layoutPropertyChanges()) {
- m_map->setLayoutProperty(change.layer, change.property, change.value);
+ m_map->setLayoutProperty(change.value("layer").toString(), change.value("property").toString(), change.value("value"));
}
quickMap->layoutPropertyChanges().clear();
}
if (!quickMap->paintPropertyChanges().empty()) {
for (const auto& change: quickMap->paintPropertyChanges()) {
- m_map->setPaintProperty(change.layer, change.property, change.value, change.klass);
+ m_map->setPaintProperty(change.value("layer").toString(), change.value("property").toString(), change.value("value"), change.value("class").toString());
}
quickMap->paintPropertyChanges().clear();
}
diff --git a/platform/qt/src/qquickmapboxglstyleproperty.cpp b/platform/qt/src/qquickmapboxglstyleproperty.cpp
index 77e6a00583..ffded9c9e7 100644
--- a/platform/qt/src/qquickmapboxglstyleproperty.cpp
+++ b/platform/qt/src/qquickmapboxglstyleproperty.cpp
@@ -18,13 +18,13 @@ QQuickMapboxGLPaintStyleProperty::QQuickMapboxGLPaintStyleProperty(QQuickItem *p
void QQuickMapboxGLLayoutStyleProperty::updateParent()
{
- if (m_layer.isNull() || m_property.isNull() || m_value.isNull()) {
+ if (m_map.value("layer").isNull() || m_map.value("property").isNull() || m_map.value("value").isNull()) {
return;
}
QQuickMapboxGL *map = qobject_cast<QQuickMapboxGL *>(parentItem());
if (map) {
- map->setLayoutProperty(layer(), property(), m_value);
+ map->setLayoutProperty(layer(), property(), value());
} else {
qWarning() << "Style property requires QQuickMapboxGL as parent item.";
}
@@ -32,13 +32,13 @@ void QQuickMapboxGLLayoutStyleProperty::updateParent()
void QQuickMapboxGLPaintStyleProperty::updateParent()
{
- if (m_layer.isNull() || m_property.isNull() || m_value.isNull()) {
+ if (m_map.value("layer").isNull() || m_map.value("property").isNull() || m_map.value("value").isNull()) {
return;
}
QQuickMapboxGL *map = qobject_cast<QQuickMapboxGL *>(parentItem());
if (map) {
- map->setPaintProperty(layer(), property(), m_value, styleClass());
+ map->setPaintProperty(layer(), property(), value(), styleClass());
} else {
qWarning() << "Style property requires QQuickMapboxGL as parent item.";
}
@@ -55,64 +55,64 @@ void QQuickMapboxGLStyleProperty::itemChange(QQuickItem::ItemChange change, cons
void QQuickMapboxGLStyleProperty::setLayer(const QString &layer)
{
- if (layer == m_layer.toString()) {
+ if (m_map.value("layer").toString() == layer) {
return;
}
- m_layer = layer;
+ m_map["layer"] = layer;
emit layerChanged(layer);
updateParent();
}
QString QQuickMapboxGLStyleProperty::layer() const
{
- return m_layer.toString();
+ return m_map.value("layer").toString();
}
void QQuickMapboxGLStyleProperty::setProperty(const QString &property)
{
- if (property == m_property.toString()) {
+ if (m_map.value("property").toString() == property) {
return;
}
- m_property = property;
+ m_map["property"] = property;
emit propertyChanged(property);
updateParent();
}
QString QQuickMapboxGLStyleProperty::property() const
{
- return m_property.toString();
+ return m_map.value("property").toString();
}
void QQuickMapboxGLStyleProperty::setValue(const QVariant &value)
{
- if (value == m_value) {
+ if (m_map.value("value") == value) {
return;
}
- m_value = value;
+ m_map["value"] = value;
emit valueChanged(value);
updateParent();
}
QVariant QQuickMapboxGLStyleProperty::value() const
{
- return m_value;
+ return m_map.value("value");
}
void QQuickMapboxGLPaintStyleProperty::setStyleClass(const QString &styleClass)
{
- if (styleClass == m_class.toString()) {
+ if (m_map.value("class").toString() == styleClass) {
return;
}
- m_class = styleClass;
+ m_map["class"] = styleClass;
emit classChanged(styleClass);
updateParent();
}
QString QQuickMapboxGLPaintStyleProperty::styleClass() const
{
- return m_class.toString();
+ return m_map.value("class").toString();
}