summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-12-08 12:42:37 +0100
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-12-08 16:36:38 +0100
commita8c2688ca315a14dc2033ddf3ca21c2d9914587d (patch)
tree6ae444eea2ede1ec7b9bf00bc974282df6988319 /platform/qt
parent0eede631cec6c62184dfdc1525c9d904843f8f98 (diff)
downloadqtlocation-mapboxgl-a8c2688ca315a14dc2033ddf3ca21c2d9914587d.tar.gz
[qt] Added copyrightsChanged() signal
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/include/qmapboxgl.hpp1
-rw-r--r--platform/qt/src/qmapboxgl.cpp11
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp1
3 files changed, 13 insertions, 0 deletions
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index d3937ce083..2361b78f8f 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -213,6 +213,7 @@ public slots:
signals:
void needsRendering();
void mapChanged(QMapbox::MapChange);
+ void copyrightsChanged(const QString &copyrightsHtml);
private:
Q_DISABLE_COPY(QMapboxGL)
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 5f04629831..62fe778035 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -847,6 +847,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
fileSourceObj->setAccessToken(settings.accessToken().toStdString());
connect(this, SIGNAL(needsRendering()), q_ptr, SIGNAL(needsRendering()), Qt::QueuedConnection);
connect(this, SIGNAL(mapChanged(QMapbox::MapChange)), q_ptr, SIGNAL(mapChanged(QMapbox::MapChange)), Qt::QueuedConnection);
+ connect(this, SIGNAL(copyrightsChanged(QString)), q_ptr, SIGNAL(copyrightsChanged(QString)), Qt::QueuedConnection);
}
QMapboxGLPrivate::~QMapboxGLPrivate()
@@ -882,6 +883,16 @@ void QMapboxGLPrivate::invalidate()
void QMapboxGLPrivate::notifyMapChange(mbgl::MapChange change)
{
+ if (change == mbgl::MapChangeSourceDidChange) {
+ std::string attribution;
+ for (const auto& source : mapObj->getSources()) {
+ // Avoid duplicates by using the most complete attribution HTML snippet.
+ if (source->getAttribution() && (attribution.size() < source->getAttribution()->size()))
+ attribution = *source->getAttribution();
+ }
+ emit copyrightsChanged(QString::fromStdString(attribution));
+ }
+
emit mapChanged(static_cast<QMapbox::MapChange>(change));
}
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index 74ee207d09..bfa5b8c326 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -51,4 +51,5 @@ public slots:
signals:
void needsRendering();
void mapChanged(QMapbox::MapChange);
+ void copyrightsChanged(const QString &copyrightsHtml);
};