Commit 3bdabea8 authored by Kai Koehne's avatar Kai Koehne
Browse files

Cache dynamic properties.

(Patch done by marco)
parent 66efbc9a
......@@ -8,18 +8,20 @@
namespace QmlDesigner {
namespace Internal {
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer &nodeInstance)
: QDeclarativeOpenMetaObject(nodeInstance->object()),
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer &nodeInstance, QDeclarativeEngine *engine)
: QDeclarativeOpenMetaObject(nodeInstance->object(), new QDeclarativeOpenMetaObjectType(nodeInstance->object()->metaObject(), engine)),
m_nodeInstance(nodeInstance),
m_context(nodeInstance->modelNode().isRootNode() ? nodeInstance->context() : 0)
{
setCached(true);
}
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix)
: QDeclarativeOpenMetaObject(object),
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QDeclarativeEngine *engine)
: QDeclarativeOpenMetaObject(object, new QDeclarativeOpenMetaObjectType(object->metaObject(), engine)),
m_nodeInstance(nodeInstance),
m_prefix(prefix)
{
setCached(true);
}
void NodeInstanceMetaObject::createNewProperty(const QString &name)
......
......@@ -14,8 +14,8 @@ typedef QWeakPointer<ObjectNodeInstance> ObjectNodeInstanceWeakPointer;
class NodeInstanceMetaObject : public QDeclarativeOpenMetaObject
{
public:
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QDeclarativeEngine *engine);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QDeclarativeEngine *engine);
void createNewProperty(const QString &name);
protected:
......
......@@ -176,12 +176,12 @@ void ObjectNodeInstance::initializePropertyWatcher(const ObjectNodeInstance::Poi
{
if (!objectNodeInstance->modelNode().metaInfo().isComponent()) { // TODO: this is a nasty workaround which needs to be removed
const QMetaObject *metaObject = objectNodeInstance->object()->metaObject();
m_metaObject = new NodeInstanceMetaObject(objectNodeInstance);
m_metaObject = new NodeInstanceMetaObject(objectNodeInstance, nodeInstanceView()->engine());
for(int propertyIndex = QObject::staticMetaObject.propertyCount(); propertyIndex < metaObject->propertyCount(); propertyIndex++) {
if (QDeclarativeMetaType::isQObject(metaObject->property(propertyIndex).userType())) {
QObject *propertyObject = QDeclarativeMetaType::toQObject(metaObject->property(propertyIndex).read(objectNodeInstance->object()));
if (propertyObject && hasPropertiesWitoutNotifications(propertyObject->metaObject())) {
new NodeInstanceMetaObject(objectNodeInstance, propertyObject, metaObject->property(propertyIndex).name());
new NodeInstanceMetaObject(objectNodeInstance, propertyObject, metaObject->property(propertyIndex).name(), nodeInstanceView()->engine());
}
}
}
......
Supports Markdown
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