[Qt] Added QQuickMapboxGLStyle

A QQuickMapboxGLStyleProperty being a child of QQuickMapboxGLStyle
assures that only properties associated with that particular style will
reflect on the map - and that happens only when the style is the current
set via style property.
This commit is contained in:
Bruno de Oliveira Abinader
2016-08-05 16:32:31 +03:00
parent 45da1abbe1
commit 8843bebee2
9 changed files with 161 additions and 32 deletions

View File

@@ -182,13 +182,21 @@ void QQuickMapboxGL::pan(int dx, int dy)
update();
}
void QQuickMapboxGL::setStyle(const QString &styleUrl)
void QQuickMapboxGL::setStyle(QQuickMapboxGLStyle *style)
{
if (m_style == styleUrl) {
if (style == m_style) {
return;
}
m_style = styleUrl;
disconnect(style, SIGNAL(urlChanged(QString)), this, SLOT(onStyleChanged()));
disconnect(style, SIGNAL(propertyUpdated(QVariantMap)), this, SLOT(onStylePropertyUpdated(QVariantMap)));
delete m_style;
m_style = style;
if (style) {
style->setParentItem(this);
connect(style, SIGNAL(urlChanged(QString)), this, SLOT(onStyleChanged()));
connect(style, SIGNAL(propertyUpdated(QVariantMap)), this, SLOT(onStylePropertyUpdated(QVariantMap)));
}
m_syncState |= StyleNeedsSync;
update();
@@ -196,7 +204,7 @@ void QQuickMapboxGL::setStyle(const QString &styleUrl)
emit styleChanged();
}
QString QQuickMapboxGL::style() const
QQuickMapboxGLStyle *QQuickMapboxGL::style() const
{
return m_style;
}
@@ -295,3 +303,11 @@ void QQuickMapboxGL::onStylePropertyUpdated(const QVariantMap &params)
update();
}
void QQuickMapboxGL::onStyleChanged()
{
m_syncState |= StyleNeedsSync;
update();
emit styleChanged();
}