summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp90
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap_p.h7
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp2
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h2
4 files changed, 31 insertions, 70 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 2ee6836b..be08c3a4 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -50,6 +50,7 @@
#include <QtQuick/QSGRectangleNode>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQml/qqmlinfo.h>
+#include <QtQuick/private/qquickitem_p.h>
#include <cmath>
#ifndef M_PI
@@ -186,8 +187,6 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
setFlags(QQuickItem::ItemHasContents | QQuickItem::ItemClipsChildrenToShape);
setFiltersChildMouseEvents(true);
- connect(this, SIGNAL(childrenChanged()), this, SLOT(onMapChildrenChanged()), Qt::QueuedConnection);
-
m_activeMapType = new QDeclarativeGeoMapType(QGeoMapType(QGeoMapType::NoMap,
tr("No Map"),
tr("No Map"), false, false, 0, QByteArrayLiteral("")), this);
@@ -246,71 +245,6 @@ QDeclarativeGeoMap::~QDeclarativeGeoMap()
delete m_map;
}
-/*!
- \internal
-*/
-void QDeclarativeGeoMap::onMapChildrenChanged()
-{
- if (!m_componentCompleted || !m_initialized)
- return;
-
- int maxChildZ = 0;
- QObjectList kids = children();
- bool foundCopyrights = false;
-
- for (int i = 0; i < kids.size(); ++i) {
- QDeclarativeGeoMapCopyrightNotice *copyrights = qobject_cast<QDeclarativeGeoMapCopyrightNotice *>(kids.at(i));
- if (copyrights) {
- foundCopyrights = true;
- } else {
- QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i));
- if (mapItem) {
- if (mapItem->z() > maxChildZ)
- maxChildZ = mapItem->z();
- }
- }
- }
-
- QDeclarativeGeoMapCopyrightNotice *copyrights = m_copyrights.data();
- // if copyrights object not found within the map's children
- if (!foundCopyrights) {
- // if copyrights object was deleted!
- if (!copyrights) {
- // create a new one and set its parent, re-assign it to the weak pointer, then connect the copyrights-change signal
- m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
- m_copyrights->onCopyrightsStyleSheetChanged(m_map->copyrightsStyleSheet());
-
- copyrights = m_copyrights.data();
-
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
- copyrights, SLOT(copyrightsChanged(QImage)));
- connect(m_map, SIGNAL(copyrightsChanged(QImage)),
- this, SIGNAL(copyrightsChanged(QImage)));
-
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
- copyrights, SLOT(copyrightsChanged(QString)));
- connect(m_map, SIGNAL(copyrightsChanged(QString)),
- this, SIGNAL(copyrightsChanged(QString)));
-
- connect(m_map, SIGNAL(copyrightsStyleSheetChanged(QString)),
- copyrights, SLOT(onCopyrightsStyleSheetChanged(QString)));
-
- connect(copyrights, SIGNAL(linkActivated(QString)),
- this, SIGNAL(copyrightLinkActivated(QString)));
-
- // set visibility of copyright notice
- copyrights->setCopyrightsVisible(m_copyrightsVisible);
-
- } else {
- // just re-set its parent.
- copyrights->setParent(this);
- }
- }
-
- // put the copyrights notice object at the highest z order
- copyrights->setCopyrightsZ(maxChildZ + 1);
-}
-
static QDeclarativeGeoMapType *findMapType(const QList<QDeclarativeGeoMapType *> &types, const QGeoMapType &type)
{
for (int i = 0; i < types.size(); ++i)
@@ -734,6 +668,7 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
/* COPY NOTICE SETUP */
m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this);
+ m_copyrights->setCopyrightsZ(m_maxChildZ + 1);
m_copyrights->setCopyrightsVisible(m_copyrightsVisible);
m_copyrights->setMapSource(this);
@@ -1563,6 +1498,27 @@ QGeoServiceProvider::Error QDeclarativeGeoMap::error() const
return m_error;
}
+void QDeclarativeGeoMap::itemChange(ItemChange change, const ItemChangeData &value)
+{
+ if (change == ItemChildAddedChange) {
+ QQuickItem *child = value.item;
+ QQuickItem *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(child);
+ if (!mapItem)
+ mapItem = qobject_cast<QDeclarativeGeoMapItemGroup *>(child);
+
+ if (mapItem) {
+ qreal z = mapItem->z();
+ if (z > m_maxChildZ) { // Ignore children removal
+ m_maxChildZ = z;
+ // put the copyrights notice object at the highest z order
+ if (m_copyrights)
+ m_copyrights->setCopyrightsZ(m_maxChildZ + 1);
+ }
+ }
+ }
+ QQuickItem::itemChange(change, value);
+}
+
/*!
\internal
*/
diff --git a/src/location/declarativemaps/qdeclarativegeomap_p.h b/src/location/declarativemaps/qdeclarativegeomap_p.h
index 6b765269..f357d322 100644
--- a/src/location/declarativemaps/qdeclarativegeomap_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomap_p.h
@@ -61,6 +61,7 @@
#include <QtGui/QColor>
#include <QtPositioning/qgeorectangle.h>
#include <QtLocation/private/qgeomap_p.h>
+#include <QtQuick/private/qquickitemchangelistener_p.h>
QT_BEGIN_NAMESPACE
@@ -183,6 +184,9 @@ public:
QString errorString() const;
QGeoServiceProvider::Error error() const;
+ // From QQuickItem
+ void itemChange(ItemChange, const ItemChangeData &) override;
+
Q_SIGNALS:
void pluginChanged(QDeclarativeGeoServiceProvider *plugin);
void zoomLevelChanged(qreal zoomLevel);
@@ -233,7 +237,6 @@ protected:
private Q_SLOTS:
void mappingManagerInitialized();
void pluginReady();
- void onMapChildrenChanged();
void onSupportedMapTypesChanged();
void onCameraCapabilitiesChanged(const QGeoCameraCapabilities &oldCameraCapabilities);
void onAttachedCopyrightNoticeVisibilityChanged();
@@ -285,6 +288,8 @@ private:
qreal m_userMaximumFieldOfView;
int m_copyNoticesVisible = 0;
+ qreal m_maxChildZ = 0;
+
friend class QDeclarativeGeoMapItem;
friend class QDeclarativeGeoMapItemView;
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
index 9edcafed..2a7fd829 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice.cpp
@@ -297,7 +297,7 @@ bool QDeclarativeGeoMapCopyrightNotice::copyrightsVisible() const
/*!
\internal
*/
-void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(int copyrightsZ)
+void QDeclarativeGeoMapCopyrightNotice::setCopyrightsZ(qreal copyrightsZ)
{
setZ(copyrightsZ);
update();
diff --git a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
index 9b28299f..73ce48f1 100644
--- a/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapcopyrightsnotice_p.h
@@ -70,7 +70,7 @@ public:
QDeclarativeGeoMapCopyrightNotice(QQuickItem *parent = Q_NULLPTR);
~QDeclarativeGeoMapCopyrightNotice();
- void setCopyrightsZ(int copyrightsZ);
+ void setCopyrightsZ(qreal copyrightsZ);
void setCopyrightsVisible(bool visible);
bool copyrightsVisible() const;