summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli.qt@gmail.com>2020-01-05 21:13:53 +0100
committerpaolo <paolo.angelelli.qt@gmail.com>2020-01-18 14:38:53 +0100
commitf4a98904855b57c6ad42f9ead29737d0201b6733 (patch)
treef287e8fe100c4ec79369c77db3a49d99f3a8f5ca
parent8e53b4913946801f5ba51807feda21778f264bf0 (diff)
downloadqtlocation-f4a98904855b57c6ad42f9ead29737d0201b6733.tar.gz
Fix MapObjectView not setting properties
Set parent for incubated objects in MapObjectView to the view. Also properly set component completed when removing the view from a map and then readding it. Finally silence the useless warning about MapObjectView being unsupported, as the default MOV is basically what's wanted. Change-Id: Iecbc345ced99754d0d09112b4b30eaca2bb078e5 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/location/declarativemaps/qgeomapobject.cpp6
-rw-r--r--src/location/labs/qmapobjectview.cpp14
2 files changed, 15 insertions, 5 deletions
diff --git a/src/location/declarativemaps/qgeomapobject.cpp b/src/location/declarativemaps/qgeomapobject.cpp
index 00faac9b..b0a10806 100644
--- a/src/location/declarativemaps/qgeomapobject.cpp
+++ b/src/location/declarativemaps/qgeomapobject.cpp
@@ -193,8 +193,10 @@ void QGeoMapObject::setMap(QGeoMap *map)
if (map) {
bool oldVisible = d_ptr->m_visible;
bool oldCmponentCompleted = d_ptr->m_componentCompleted;
- if (!map->createMapObjectImplementation(this))
- qWarning() << "Unsupported type " << type();
+ if (!map->createMapObjectImplementation(this)) {
+ if (type() != ViewType)
+ qWarning() << "Unsupported type " << type();
+ }
// old implementation gets destroyed if/when d_ptr gets replaced
d_ptr->m_componentCompleted = oldCmponentCompleted;
d_ptr->setVisible(oldVisible);
diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp
index 8cbf8ded..54d384fb 100644
--- a/src/location/labs/qmapobjectview.cpp
+++ b/src/location/labs/qmapobjectview.cpp
@@ -339,8 +339,10 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
for (int idx = c.start(); idx < c.end(); idx++) {
m_instantiatedMapObjects.insert(idx, nullptr);
QGeoMapObject *mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(idx, incubationMode));
- if (mo) // if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect.
+ if (mo) {// if not, a createdItem signal will be emitted later, else it has been emitted already while createBlocker is in effect.
+ mo->setParent(this);
addMapObjectToMap(mo, idx);
+ }
}
}
}
@@ -395,10 +397,12 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/)
// or else, it will be destroyed exiting this scope
QGeoMapObject *mo = nullptr;
mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode));
- if (mo)
+ if (mo) {
+ mo->setParent(this);
addMapObjectToMap(mo, index);
- else
+ } else {
qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object";
+ }
}
@@ -436,7 +440,11 @@ void QMapObjectView::setMap(QGeoMap *map)
// Map was set, now it has ben re-set to NULL
flushDelegateModel();
flushUserAddedMapObjects();
+ bool oldVisible = d_ptr->m_visible;
+ bool oldCmponentCompleted = d_ptr->m_componentCompleted;
d_ptr = new QMapObjectViewPrivateDefault(*d);
+ d_ptr->m_componentCompleted = oldCmponentCompleted;
+ d_ptr->setVisible(oldVisible);
} else if (d->m_componentCompleted) {
// Map was null, now it's set AND delegateModel is already complete.
// some delegates may have been incubated but not added to the map.