forked from qt-creator/qt-creator
QmlPuppet: Register callback for notifyPropertyChange
MetaObject cannot have a dependency on ObjectNodeInstance. Instead we register a callback. Change-Id: I9f6e096c67caf1abd525201c9bacd363d31a2fa2 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
0321f6e1a7
commit
c9eb75e2f8
@@ -110,6 +110,16 @@ namespace {
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static NodeInstanceServer *nodeInstanceServerInstance = 0;
|
||||
|
||||
static void notifyPropertyChangeCallBackFunction(QObject *object, const PropertyName &propertyName)
|
||||
{
|
||||
qint32 id = nodeInstanceServerInstance->instanceForObject(object).instanceId();
|
||||
nodeInstanceServerInstance->notifyPropertyChange(id, propertyName);
|
||||
}
|
||||
|
||||
static void (*notifyPropertyChangeCallBackPointer)(QObject *, const PropertyName &) = ¬ifyPropertyChangeCallBackFunction;
|
||||
|
||||
NodeInstanceServer::NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
|
||||
NodeInstanceServerInterface(),
|
||||
m_childrenChangeEventFilter(new Internal::ChildrenChangeEventFilter(this)),
|
||||
@@ -122,6 +132,8 @@ NodeInstanceServer::NodeInstanceServer(NodeInstanceClientInterface *nodeInstance
|
||||
qmlRegisterType<DummyContextObject>("QmlDesigner", 1, 0, "DummyContextObject");
|
||||
|
||||
connect(m_childrenChangeEventFilter.data(), SIGNAL(childrenChanged(QObject*)), this, SLOT(emitParentChanged(QObject*)));
|
||||
nodeInstanceServerInstance = this;
|
||||
Internal::QmlPrivateGate::registerNotifyPropertyChangeCallBack(notifyPropertyChangeCallBackPointer);
|
||||
}
|
||||
|
||||
NodeInstanceServer::~NodeInstanceServer()
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Internal {
|
||||
namespace QmlPrivateGate {
|
||||
|
||||
static QHash<QDynamicMetaObjectData *, bool> nodeInstanceMetaObjectList;
|
||||
static void (*notifyPropertyChangeCallBack)(QObject*, const PropertyName &propertyName) = 0;
|
||||
|
||||
struct MetaPropertyData {
|
||||
inline QPair<QVariant, bool> &getDataRef(int idx) {
|
||||
@@ -328,9 +329,11 @@ void MetaObject::notifyPropertyChange(int id)
|
||||
|
||||
if (objectNodeInstance && objectNodeInstance->nodeInstanceServer()) {
|
||||
if (id < propertyOffset()) {
|
||||
objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), propertyById.name());
|
||||
if (notifyPropertyChangeCallBack)
|
||||
notifyPropertyChangeCallBack(myObject(), propertyById.name());
|
||||
} else {
|
||||
objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), name(id - propertyOffset()));
|
||||
if (notifyPropertyChangeCallBack)
|
||||
notifyPropertyChangeCallBack(myObject(), name(id - propertyOffset()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -350,6 +353,11 @@ void MetaObject::copyTypeMetaObject()
|
||||
*static_cast<QMetaObject *>(this) = *m_type->metaObject();
|
||||
}
|
||||
|
||||
void MetaObject::registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &))
|
||||
{
|
||||
notifyPropertyChangeCallBack = callback;
|
||||
}
|
||||
|
||||
} // namespace QmlPrivateGate
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -58,6 +58,7 @@ class MetaObject : public QQmlVMEMetaObject
|
||||
public:
|
||||
~MetaObject();
|
||||
|
||||
static void registerNotifyPropertyChangeCallBack(void (*callback)(QObject*, const PropertyName &propertyName));
|
||||
|
||||
protected:
|
||||
MetaObject(const ObjectNodeInstancePointer &nodeInstance, QQmlEngine *engine);
|
||||
|
||||
@@ -779,6 +779,11 @@ void getPropertyCache(QObject *object, QQmlEngine *engine)
|
||||
QQmlEnginePrivate::get(engine)->cache(object->metaObject());
|
||||
}
|
||||
|
||||
void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &))
|
||||
{
|
||||
MetaObject::registerNotifyPropertyChangeCallBack(callback);
|
||||
}
|
||||
|
||||
ComponentCompleteDisabler::ComponentCompleteDisabler()
|
||||
{
|
||||
DesignerSupport::disableComponentComplete();
|
||||
|
||||
@@ -127,9 +127,12 @@ public:
|
||||
|
||||
} // namespace PropertyChanges
|
||||
|
||||
|
||||
bool isSubclassOf(QObject *object, const QByteArray &superTypeName);
|
||||
void getPropertyCache(QObject *object, QQmlEngine *engine);
|
||||
|
||||
void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &));
|
||||
|
||||
} // namespace QmlPrivateGate
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user