summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/location/declarativemaps/qdeclarativegeomap.cpp9
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp12
-rw-r--r--src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h5
3 files changed, 20 insertions, 6 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomap.cpp b/src/location/declarativemaps/qdeclarativegeomap.cpp
index 1f2886d8..f5d2bdb5 100644
--- a/src/location/declarativemaps/qdeclarativegeomap.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomap.cpp
@@ -1849,13 +1849,11 @@ void QDeclarativeGeoMap::clearMapItems()
*/
void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap()) // || Already added to some map
return;
+ itemGroup->setQuickMap(this);
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
- if (m_mapItemGroups.contains(g))
- return;
-
m_mapItemGroups.append(g);
const QList<QQuickItem *> quickKids = g->childItems();
for (auto c: quickKids) {
@@ -1877,7 +1875,7 @@ void QDeclarativeGeoMap::addMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
*/
void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGroup)
{
- if (!itemGroup)
+ if (!itemGroup || itemGroup->quickMap() != this) // cant remove an itemGroup added to another map
return;
QPointer<QDeclarativeGeoMapItemGroup> g(itemGroup);
@@ -1890,6 +1888,7 @@ void QDeclarativeGeoMap::removeMapItemGroup(QDeclarativeGeoMapItemGroup *itemGro
if (mapItem)
removeMapItem(mapItem);
}
+ itemGroup->setQuickMap(nullptr);
itemGroup->setParentItem(0);
}
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp b/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
index ee382353..59aaaa26 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
+++ b/src/location/declarativemaps/qdeclarativegeomapitemgroup.cpp
@@ -135,7 +135,7 @@ QT_BEGIN_NAMESPACE
\image api-mapitemgroup.png
*/
-QDeclarativeGeoMapItemGroup::QDeclarativeGeoMapItemGroup(QQuickItem *parent): QQuickItem(parent)
+QDeclarativeGeoMapItemGroup::QDeclarativeGeoMapItemGroup(QQuickItem *parent): QQuickItem(parent), m_quickMap(nullptr)
{
}
@@ -145,4 +145,14 @@ QDeclarativeGeoMapItemGroup::~QDeclarativeGeoMapItemGroup()
}
+void QDeclarativeGeoMapItemGroup::setQuickMap(QDeclarativeGeoMap *quickMap)
+{
+ m_quickMap = quickMap;
+}
+
+QDeclarativeGeoMap *QDeclarativeGeoMapItemGroup::quickMap() const
+{
+ return m_quickMap;
+}
+
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h b/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
index 1b008d71..f91d291c 100644
--- a/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
+++ b/src/location/declarativemaps/qdeclarativegeomapitemgroup_p.h
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+class QDeclarativeGeoMap;
class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemGroup : public QQuickItem
{
Q_OBJECT
@@ -60,6 +61,10 @@ public:
explicit QDeclarativeGeoMapItemGroup(QQuickItem *parent = 0);
virtual ~QDeclarativeGeoMapItemGroup();
+ void setQuickMap(QDeclarativeGeoMap *quickMap);
+ QDeclarativeGeoMap *quickMap() const;
+private:
+ QDeclarativeGeoMap *m_quickMap;
};
QT_END_NAMESPACE