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