summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauri Laanmets <lauri.laanmets@eesti.ee>2021-09-30 19:09:16 +0300
committerIvan Solovev <ivan.solovev@qt.io>2021-11-09 10:28:35 +0100
commit92392b471cbcfcf386cd0ba7c99fc4a9297f018a (patch)
tree4104a06c5b2ad48a4085ecb3f046cddd31f00315
parente7af7ba73dfce236ff2627aacd6d261b25b125f4 (diff)
downloadqtlocation-92392b471cbcfcf386cd0ba7c99fc4a9297f018a.tar.gz
Remove QAbstractDeclarativeData::parentChanged
This method was removed from qtbase in e8b7e4e96a23b87011abeb1e4f5f694654866e3f. This commit removes the usage of this method from qtlocation and attempts to achieve the same behavior by introducing a custom setParentAndNotify() method which emits the parentChanged() signal. The code is also updated to make use of the new method. This is part of a bigger work to port QtLocation maps to Qt6. Task-number: QTBUG-96795 Change-Id: I4523cf567b4510fc17473a37c689c689ee53130e Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/location/declarativemaps/qparameterizableobject.cpp13
-rw-r--r--src/location/declarativemaps/qparameterizableobject_p.h2
-rw-r--r--src/location/labs/qmapobjectview.cpp4
3 files changed, 9 insertions, 10 deletions
diff --git a/src/location/declarativemaps/qparameterizableobject.cpp b/src/location/declarativemaps/qparameterizableobject.cpp
index 25c535e0..b1e588e6 100644
--- a/src/location/declarativemaps/qparameterizableobject.cpp
+++ b/src/location/declarativemaps/qparameterizableobject.cpp
@@ -94,11 +94,9 @@ public:
static bool initialized = false;
if (!initialized) {
initialized = true;
- QAbstractDeclarativeData::parentChanged = parentChanged;
}
}
- static void parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p);
};
Q_GLOBAL_STATIC(QParameterizableObjectData, parametrizableObjectData)
@@ -109,13 +107,12 @@ QParameterizableObject::QParameterizableObject(QObject *parent)
QObjectPrivate::get(this)->declarativeData = parametrizableObjectData;
}
-void QParameterizableObjectData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p)
+void QParameterizableObject::setParentAndNotify(QObject *parent)
{
- Q_UNUSED(p);
- Q_UNUSED(d);
- QParameterizableObject *po = qobject_cast<QParameterizableObject *>(o);
- if (po)
- po->parentChanged();
+ QObject *oldParent = this->parent();
+ QObject::setParent(parent);
+ if (parent != oldParent)
+ emit parentChanged();
}
QT_END_NAMESPACE
diff --git a/src/location/declarativemaps/qparameterizableobject_p.h b/src/location/declarativemaps/qparameterizableobject_p.h
index cf393aee..21a096e0 100644
--- a/src/location/declarativemaps/qparameterizableobject_p.h
+++ b/src/location/declarativemaps/qparameterizableobject_p.h
@@ -77,6 +77,8 @@ public:
return res;
}
+ void setParentAndNotify(QObject *parent);
+
Q_SIGNALS:
void parentChanged();
diff --git a/src/location/labs/qmapobjectview.cpp b/src/location/labs/qmapobjectview.cpp
index a5143c54..a015d425 100644
--- a/src/location/labs/qmapobjectview.cpp
+++ b/src/location/labs/qmapobjectview.cpp
@@ -340,7 +340,7 @@ void QMapObjectView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
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.
- mo->setParent(this);
+ mo->setParentAndNotify(this);
addMapObjectToMap(mo, idx);
}
}
@@ -398,7 +398,7 @@ void QMapObjectView::createdItem(int index, QObject * /*object*/)
QGeoMapObject *mo = nullptr;
mo = qobject_cast<QGeoMapObject *>(m_delegateModel->object(index, incubationMode));
if (mo) {
- mo->setParent(this);
+ mo->setParentAndNotify(this);
addMapObjectToMap(mo, index);
} else {
qWarning() << "QQmlDelegateModel::object called in createdItem for " << index << " produced a null object";