| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2014-01-07 13:27:11 +01:00
										 |  |  | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							|  |  |  | ** a written agreement between you and Digia.  For licensing terms and | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** conditions see http://www.qt.io/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
					
						
							| 
									
										
										
										
											2014-10-01 13:21:18 +02:00
										 |  |  | ** General Public License version 2.1 or version 3 as published by the Free | 
					
						
							|  |  |  | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | 
					
						
							|  |  |  | ** LICENSE.LGPLv3 included in the packaging of this file.  Please review the | 
					
						
							|  |  |  | ** following information to ensure the GNU Lesser General Public License | 
					
						
							|  |  |  | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
 | 
					
						
							|  |  |  | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** In addition, as a special exception, Digia gives you certain additional | 
					
						
							|  |  |  | ** rights.  These rights are described in the Digia Qt LGPL Exception | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "nodeinstancemetaobject.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "objectnodeinstance.h"
 | 
					
						
							|  |  |  | #include <QSharedPointer>
 | 
					
						
							|  |  |  | #include <QMetaProperty>
 | 
					
						
							|  |  |  | #include <qnumeric.h>
 | 
					
						
							|  |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | #include <private/qqmlengine_p.h>
 | 
					
						
							|  |  |  | #include <private/qqmlpropertycache_p.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | namespace QmlDesigner { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | static QHash<QDynamicMetaObjectData *, bool> nodeInstanceMetaObjectList; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct MetaPropertyData { | 
					
						
							|  |  |  |     inline QPair<QVariant, bool> &getDataRef(int idx) { | 
					
						
							|  |  |  |         while (m_data.count() <= idx) | 
					
						
							|  |  |  |             m_data << QPair<QVariant, bool>(QVariant(), false); | 
					
						
							|  |  |  |         return m_data[idx]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     inline QVariant &getData(int idx) { | 
					
						
							|  |  |  |         QPair<QVariant, bool> &prop = getDataRef(idx); | 
					
						
							|  |  |  |         if (!prop.second) { | 
					
						
							|  |  |  |             prop.first = QVariant(); | 
					
						
							|  |  |  |             prop.second = true; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return prop.first; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     inline bool hasData(int idx) const { | 
					
						
							|  |  |  |         if (idx >= m_data.count()) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         return m_data[idx].second; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     inline int count() { return m_data.count(); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QList<QPair<QVariant, bool> > m_data; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static bool constructedMetaData(const QQmlVMEMetaData* data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return data->varPropertyCount == 0 | 
					
						
							|  |  |  |             && data->propertyCount == 0 | 
					
						
							|  |  |  |             && data->aliasCount == 0 | 
					
						
							|  |  |  |             && data->signalCount == 0 | 
					
						
							|  |  |  |             && data->methodCount == 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static QQmlVMEMetaData* fakeMetaData() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QQmlVMEMetaData* data = new QQmlVMEMetaData; | 
					
						
							|  |  |  |     data->varPropertyCount = 0; | 
					
						
							|  |  |  |     data->propertyCount = 0; | 
					
						
							|  |  |  |     data->aliasCount = 0; | 
					
						
							|  |  |  |     data->signalCount = 0; | 
					
						
							|  |  |  |     data->methodCount = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return data; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static const QQmlVMEMetaData* vMEMetaDataForObject(QObject *object) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QQmlVMEMetaObject *metaObject = QQmlVMEMetaObject::get(object); | 
					
						
							|  |  |  |     if (metaObject) | 
					
						
							|  |  |  |         return metaObject->metaData; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return fakeMetaData(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static QQmlPropertyCache *cacheForObject(QObject *object, QQmlEngine *engine) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QQmlVMEMetaObject *metaObject = QQmlVMEMetaObject::get(object); | 
					
						
							|  |  |  |     if (metaObject) | 
					
						
							|  |  |  |         return metaObject->cache; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return QQmlEnginePrivate::get(engine)->cache(object); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QQmlEngine *engine) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //Avoid setting up multiple NodeInstanceMetaObjects on the same QObject
 | 
					
						
							|  |  |  |     QObjectPrivate *op = QObjectPrivate::get(nodeInstance->object()); | 
					
						
							|  |  |  |     QDynamicMetaObjectData *parent = op->metaObject; | 
					
						
							|  |  |  |     if (nodeInstanceMetaObjectList.contains(parent)) | 
					
						
							|  |  |  |         return static_cast<NodeInstanceMetaObject *>(parent); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return new NodeInstanceMetaObject(nodeInstance, engine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  | NodeInstanceMetaObject *NodeInstanceMetaObject::createNodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine) | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     //Avoid setting up multiple NodeInstanceMetaObjects on the same QObject
 | 
					
						
							|  |  |  |     QObjectPrivate *op = QObjectPrivate::get(nodeInstance->object()); | 
					
						
							|  |  |  |     QDynamicMetaObjectData *parent = op->metaObject; | 
					
						
							|  |  |  |     if (nodeInstanceMetaObjectList.contains(parent)) | 
					
						
							|  |  |  |         return static_cast<NodeInstanceMetaObject *>(parent); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return new NodeInstanceMetaObject(nodeInstance, object, prefix, engine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NodeInstanceMetaObject::init(QObject *object, QQmlEngine *engine) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     //Creating QQmlOpenMetaObjectType
 | 
					
						
							|  |  |  |     m_type = new QQmlOpenMetaObjectType(metaObjectParent(), engine); | 
					
						
							|  |  |  |     m_type->addref(); | 
					
						
							|  |  |  |     //Assigning type to this
 | 
					
						
							|  |  |  |     copyTypeMetaObject(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //Assign this to object
 | 
					
						
							|  |  |  |     QObjectPrivate *op = QObjectPrivate::get(object); | 
					
						
							|  |  |  |     op->metaObject = this; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //create cache
 | 
					
						
							|  |  |  |     cache = m_cache = QQmlEnginePrivate::get(engine)->cache(this); | 
					
						
							| 
									
										
										
										
											2012-10-29 11:17:09 +01:00
										 |  |  |     cache->addref(); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //If our parent is not a VMEMetaObject we just se the flag to false again
 | 
					
						
							|  |  |  |     if (constructedMetaData(metaData)) | 
					
						
							|  |  |  |         QQmlData::get(object)->hasVMEMetaObject = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodeInstanceMetaObjectList.insert(this, true); | 
					
						
							| 
									
										
										
										
											2012-10-29 11:17:09 +01:00
										 |  |  |     hasAssignedMetaObjectData = true; | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer &nodeInstance, QQmlEngine *engine) | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     : QQmlVMEMetaObject(nodeInstance->object(), cacheForObject(nodeInstance->object(), engine), vMEMetaDataForObject(nodeInstance->object())), | 
					
						
							|  |  |  |       m_nodeInstance(nodeInstance), | 
					
						
							|  |  |  |       m_context(engine->contextForObject(nodeInstance->object())), | 
					
						
							|  |  |  |       m_data(new MetaPropertyData), | 
					
						
							|  |  |  |       m_cache(0) | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     init(nodeInstance->object(), engine); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QQmlData *ddata = QQmlData::get(nodeInstance->object(), false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //Assign cache to object
 | 
					
						
							|  |  |  |     if (ddata && ddata->propertyCache) { | 
					
						
							| 
									
										
										
										
											2012-11-06 10:02:23 +01:00
										 |  |  |         cache->setParent(ddata->propertyCache); | 
					
						
							|  |  |  |         cache->invalidate(engine, this); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |         ddata->propertyCache = m_cache; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-11-06 10:02:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  | NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const PropertyName &prefix, QQmlEngine *engine) | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     : QQmlVMEMetaObject(object, cacheForObject(object, engine), vMEMetaDataForObject(object)), | 
					
						
							|  |  |  |       m_nodeInstance(nodeInstance), | 
					
						
							|  |  |  |       m_prefix(prefix), | 
					
						
							| 
									
										
										
										
											2012-12-08 21:26:29 +02:00
										 |  |  |       m_context(engine->contextForObject(object)), | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       m_data(new MetaPropertyData), | 
					
						
							|  |  |  |       m_cache(0) | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |       init(object, engine); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NodeInstanceMetaObject::~NodeInstanceMetaObject() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-04 19:10:17 +01:00
										 |  |  |     if (cache->count() > 1) // qml is chrashing because the property cache is not removed from the engine
 | 
					
						
							|  |  |  |         cache->release(); | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     m_type->release(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodeInstanceMetaObjectList.remove(this); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NodeInstanceMetaObject::createNewProperty(const QString &name) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-09-10 15:50:32 +02:00
										 |  |  |     int id = m_type->createProperty(name.toUtf8()); | 
					
						
							|  |  |  |     copyTypeMetaObject(); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     setValue(id, QVariant()); | 
					
						
							|  |  |  |     Q_ASSERT(id >= 0); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     Q_UNUSED(id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     //Updating cache
 | 
					
						
							| 
									
										
										
										
											2012-11-06 10:02:23 +01:00
										 |  |  |     QQmlPropertyCache *oldParent = m_cache->parent(); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     QQmlEnginePrivate::get(m_context->engine())->cache(this)->invalidate(m_context->engine(), this); | 
					
						
							| 
									
										
										
										
											2012-11-06 10:02:23 +01:00
										 |  |  |     m_cache->setParent(oldParent); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QQmlProperty property(myObject(), name, m_context); | 
					
						
							|  |  |  |     Q_ASSERT(property.isValid()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NodeInstanceMetaObject::setValue(int id, const QVariant &value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QPair<QVariant, bool> &prop = m_data->getDataRef(id); | 
					
						
							|  |  |  |     prop.first = propertyWriteValue(id, value); | 
					
						
							|  |  |  |     prop.second = true; | 
					
						
							|  |  |  |     QMetaObject::activate(myObject(), id + m_type->signalOffset(), 0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QVariant NodeInstanceMetaObject::propertyWriteValue(int, const QVariant &value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-10 15:01:15 +02:00
										 |  |  | const QAbstractDynamicMetaObject *NodeInstanceMetaObject::dynamicMetaObjectParent() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (QQmlVMEMetaObject::parent.isT1()) | 
					
						
							|  |  |  |         return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const QMetaObject *NodeInstanceMetaObject::metaObjectParent() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (QQmlVMEMetaObject::parent.isT1()) | 
					
						
							|  |  |  |         return QQmlVMEMetaObject::parent.asT1()->toDynamicMetaObject(QQmlVMEMetaObject::object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return QQmlVMEMetaObject::parent.asT2(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int NodeInstanceMetaObject::propertyOffset() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return cache->propertyOffset(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | int NodeInstanceMetaObject::openMetaCall(QMetaObject::Call call, int id, void **a) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if ((call == QMetaObject::ReadProperty || call == QMetaObject::WriteProperty) | 
					
						
							|  |  |  |             && id >= m_type->propertyOffset()) { | 
					
						
							|  |  |  |         int propId = id - m_type->propertyOffset(); | 
					
						
							|  |  |  |         if (call == QMetaObject::ReadProperty) { | 
					
						
							|  |  |  |             //propertyRead(propId);
 | 
					
						
							|  |  |  |             *reinterpret_cast<QVariant *>(a[0]) = m_data->getData(propId); | 
					
						
							|  |  |  |         } else if (call == QMetaObject::WriteProperty) { | 
					
						
							|  |  |  |             if (propId <= m_data->count() || m_data->m_data[propId].first != *reinterpret_cast<QVariant *>(a[0]))  { | 
					
						
							|  |  |  |                 //propertyWrite(propId);
 | 
					
						
							|  |  |  |                 QPair<QVariant, bool> &prop = m_data->getDataRef(propId); | 
					
						
							|  |  |  |                 prop.first = propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0])); | 
					
						
							|  |  |  |                 prop.second = true; | 
					
						
							|  |  |  |                 //propertyWritten(propId);
 | 
					
						
							|  |  |  |                 activate(myObject(), m_type->signalOffset() + propId, 0); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         QAbstractDynamicMetaObject *directParent = parent(); | 
					
						
							|  |  |  |         if (directParent) | 
					
						
							|  |  |  |             return directParent->metaCall(call, id, a); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             return myObject()->qt_metacall(call, id, a); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int NodeInstanceMetaObject::metaCall(QMetaObject::Call call, int id, void **a) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int metaCallReturnValue = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     const QMetaProperty propertyById = QQmlVMEMetaObject::property(id); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     if (call == QMetaObject::WriteProperty | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             && propertyById.userType() == QMetaType::QVariant | 
					
						
							|  |  |  |             && reinterpret_cast<QVariant *>(a[0])->type() == QVariant::Double | 
					
						
							|  |  |  |             && qIsNaN(reinterpret_cast<QVariant *>(a[0])->toDouble())) { | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         return -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (call == QMetaObject::WriteProperty | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             && propertyById.userType() == QMetaType::Double | 
					
						
							|  |  |  |             && qIsNaN(*reinterpret_cast<double*>(a[0]))) { | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         return -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (call == QMetaObject::WriteProperty | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             && propertyById.userType() == QMetaType::Float | 
					
						
							|  |  |  |             && qIsNaN(*reinterpret_cast<float*>(a[0]))) { | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         return -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QVariant oldValue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     if (call == QMetaObject::WriteProperty && !propertyById.hasNotifySignal()) | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |         oldValue = propertyById.read(myObject()); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ObjectNodeInstance::Pointer objectNodeInstance = m_nodeInstance.toStrongRef(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     QAbstractDynamicMetaObject *directParent = parent(); | 
					
						
							|  |  |  |     if (directParent && id < directParent->propertyOffset()) { | 
					
						
							|  |  |  |         metaCallReturnValue = directParent->metaCall(call, id, a); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |         openMetaCall(call, id, a); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((call == QMetaObject::WriteProperty || call == QMetaObject::ReadProperty) && metaCallReturnValue < 0) { | 
					
						
							|  |  |  |         if (objectNodeInstance | 
					
						
							|  |  |  |                 && objectNodeInstance->nodeInstanceServer() | 
					
						
							|  |  |  |                 && objectNodeInstance->nodeInstanceServer()->dummyContextObject() | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |                 && !(objectNodeInstance && !objectNodeInstance->isRootNodeInstance() | 
					
						
							|  |  |  |                      && property(id).name() == QLatin1String("parent"))) { | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             QObject *contextDummyObject = objectNodeInstance->nodeInstanceServer()->dummyContextObject(); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             int properyIndex = contextDummyObject->metaObject()->indexOfProperty(propertyById.name()); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |             if (properyIndex >= 0) | 
					
						
							|  |  |  |                 metaCallReturnValue = contextDummyObject->qt_metacall(call, properyIndex, a); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-21 13:10:24 +02:00
										 |  |  |     if (call == QMetaObject::WriteProperty | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             && !propertyById.hasNotifySignal() | 
					
						
							|  |  |  |             && oldValue != propertyById.read(myObject())) | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         notifyPropertyChange(id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return metaCallReturnValue; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NodeInstanceMetaObject::notifyPropertyChange(int id) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ObjectNodeInstance::Pointer objectNodeInstance = m_nodeInstance.toStrongRef(); | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |     const QMetaProperty propertyById = property(id); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (objectNodeInstance && objectNodeInstance->nodeInstanceServer()) { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |         if (id < propertyOffset()) { | 
					
						
							|  |  |  |             objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), m_prefix + propertyById.name()); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  |             objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), m_prefix + name(id - propertyOffset())); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 14:39:18 +02:00
										 |  |  | int NodeInstanceMetaObject::count() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_type->propertyCount(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray NodeInstanceMetaObject::name(int idx) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_type->propertyName(idx); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NodeInstanceMetaObject::copyTypeMetaObject() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     *static_cast<QMetaObject *>(this) = *m_type->metaObject(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace QmlDesigner
 |