Commit bf33e654 authored by Marco Bubke's avatar Marco Bubke
Browse files

Get in component and connect every signal to the signal watcher

This is improving the updating.
parent ae9da516
...@@ -26,10 +26,16 @@ void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Poin ...@@ -26,10 +26,16 @@ void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Poin
void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix) void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix)
{ {
if (registeredObjectList.contains(spiedObject)) // prevent cycles
return;
registeredObjectList.append(spiedObject);
for (int index = QObject::staticMetaObject.propertyOffset(); for (int index = QObject::staticMetaObject.propertyOffset();
index < spiedObject->metaObject()->propertyCount(); index < spiedObject->metaObject()->propertyCount();
index++) { index++) {
QMetaProperty metaProperty = spiedObject->metaObject()->property(index); QMetaProperty metaProperty = spiedObject->metaObject()->property(index);
// handle dot properties and connect the signals to the object
if (metaProperty.isReadable() if (metaProperty.isReadable()
&& !metaProperty.isWritable() && !metaProperty.isWritable()
&& QDeclarativeMetaType::isQObject(metaProperty.userType())) { && QDeclarativeMetaType::isQObject(metaProperty.userType())) {
...@@ -43,6 +49,28 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString & ...@@ -43,6 +49,28 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
m_indexPropertyHash.insert(methodeOffset, prefix + metaProperty.name()); m_indexPropertyHash.insert(methodeOffset, prefix + metaProperty.name());
methodeOffset++; methodeOffset++;
} }
// search recursive in objects
if (metaProperty.isReadable()
&& metaProperty.isWritable()
&& QDeclarativeMetaType::isQObject(metaProperty.userType())) {
QObject *propertyObject = QDeclarativeMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + "/");
}
// search recursive in objects list
if (metaProperty.isReadable()
&& QDeclarativeMetaType::isList(metaProperty.userType())) {
QDeclarativeListReference list(spiedObject, metaProperty.name());
if (list.canCount() && list.canAt()) {
for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i);
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + "/");
}
}
}
} }
} }
......
...@@ -27,6 +27,7 @@ protected: ...@@ -27,6 +27,7 @@ protected:
private: private:
int methodeOffset; int methodeOffset;
QHash<int, QString> m_indexPropertyHash; QHash<int, QString> m_indexPropertyHash;
QObjectList registeredObjectList;
ObjectNodeInstanceWeakPointer m_objectNodeInstance; ObjectNodeInstanceWeakPointer m_objectNodeInstance;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment