| 
									
										
										
										
											2012-11-06 15:35:19 +01:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2013-01-31 17:02:30 +01:00
										 |  |  | ** Copyright (C) 2013 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 | 
					
						
							|  |  |  | ** conditions see http://qt.digia.com/licensing.  For further information
 | 
					
						
							|  |  |  | ** use the contact form at http://qt.digia.com/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 | 
					
						
							|  |  |  | ** General Public License version 2.1 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
					
						
							|  |  |  | ** packaging of this file.  Please review the following information to | 
					
						
							|  |  |  | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
					
						
							|  |  |  | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 12:40:44 +01:00
										 |  |  | #ifndef OBJECTNODEINSTANCE_H
 | 
					
						
							|  |  |  | #define OBJECTNODEINSTANCE_H
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "nodeinstanceserver.h"
 | 
					
						
							|  |  |  | #include "nodeinstancemetaobject.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QPainter>
 | 
					
						
							|  |  |  | #include <QSharedPointer>
 | 
					
						
							|  |  |  | #include <QWeakPointer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QT_BEGIN_NAMESPACE | 
					
						
							|  |  |  | class QGraphicsItem; | 
					
						
							|  |  |  | class QQmlContext; | 
					
						
							|  |  |  | class QQmlEngine; | 
					
						
							|  |  |  | class QQmlProperty; | 
					
						
							|  |  |  | class QQmlAbstractBinding; | 
					
						
							|  |  |  | QT_END_NAMESPACE | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace QmlDesigner { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NodeInstanceServer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class QmlGraphicsItemNodeInstance; | 
					
						
							|  |  |  | class GraphicsWidgetNodeInstance; | 
					
						
							|  |  |  | class GraphicsViewNodeInstance; | 
					
						
							|  |  |  | class GraphicsSceneNodeInstance; | 
					
						
							|  |  |  | class ProxyWidgetNodeInstance; | 
					
						
							|  |  |  | class WidgetNodeInstance; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ObjectNodeInstance | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     typedef QSharedPointer<ObjectNodeInstance> Pointer; | 
					
						
							|  |  |  |     typedef QWeakPointer<ObjectNodeInstance> WeakPointer; | 
					
						
							|  |  |  |     explicit ObjectNodeInstance(QObject *object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual ~ObjectNodeInstance(); | 
					
						
							|  |  |  |     void destroy(); | 
					
						
							|  |  |  |     //void setModelNode(const ModelNode &node);
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static Pointer create(QObject *objectToBeWrapped); | 
					
						
							|  |  |  |     static QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context); | 
					
						
							|  |  |  |     static QObject *createCustomParserObject(const QString &nodeSource, const QStringList &imports, QQmlContext *context); | 
					
						
							|  |  |  |     static QObject *createComponent(const QString &componentPath, QQmlContext *context); | 
					
						
							|  |  |  |     static QObject *createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void setInstanceId(qint32 id); | 
					
						
							|  |  |  |     qint32 instanceId() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NodeInstanceServer *nodeInstanceServer() const; | 
					
						
							|  |  |  |     void setNodeInstanceServer(NodeInstanceServer *server); | 
					
						
							|  |  |  |     virtual void initializePropertyWatcher(const Pointer &objectNodeInstance); | 
					
						
							|  |  |  |     virtual void initialize(const Pointer &objectNodeInstance); | 
					
						
							|  |  |  |     virtual QImage renderImage() const; | 
					
						
							| 
									
										
										
										
											2013-04-15 13:28:48 +02:00
										 |  |  |     virtual QImage renderPreviewImage(const QSize &previewImageSize) const; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual QObject *parent() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Pointer parentInstance() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     virtual void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual void setId(const QString &id); | 
					
						
							|  |  |  |     virtual QString id() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual bool isTransition() const; | 
					
						
							|  |  |  |     virtual bool isPositioner() const; | 
					
						
							| 
									
										
										
										
											2012-09-25 17:05:00 +02:00
										 |  |  |     virtual bool isQuickItem() const; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual bool equalGraphicsItem(QGraphicsItem *item) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual QRectF boundingRect() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual QPointF position() const; | 
					
						
							|  |  |  |     virtual QSizeF size() const; | 
					
						
							|  |  |  |     virtual QTransform transform() const; | 
					
						
							|  |  |  |     virtual QTransform customTransform() const; | 
					
						
							|  |  |  |     virtual QTransform sceneTransform() const; | 
					
						
							|  |  |  |     virtual double opacity() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int penWidth() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     virtual bool hasAnchor(const PropertyName &name) const; | 
					
						
							|  |  |  |     virtual QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     virtual bool isAnchoredBySibling() const; | 
					
						
							|  |  |  |     virtual bool isAnchoredByChildren() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual double rotation() const; | 
					
						
							|  |  |  |     virtual double scale() const; | 
					
						
							|  |  |  |     virtual QList<QGraphicsTransform *> transformations() const; | 
					
						
							|  |  |  |     virtual QPointF transformOriginPoint() const; | 
					
						
							|  |  |  |     virtual double zValue() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     virtual void setPropertyVariant(const PropertyName &name, const QVariant &value); | 
					
						
							|  |  |  |     virtual void setPropertyBinding(const PropertyName &name, const QString &expression); | 
					
						
							|  |  |  |     virtual QVariant property(const PropertyName &name) const; | 
					
						
							|  |  |  |     virtual void resetProperty(const PropertyName &name); | 
					
						
							|  |  |  |     virtual void refreshProperty(const PropertyName &name); | 
					
						
							|  |  |  |     virtual QString instanceType(const PropertyName &name) const; | 
					
						
							|  |  |  |     PropertyNameList propertyNames() const; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual QList<ServerNodeInstance> childItems() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     void createDynamicProperty(const QString &PropertyName, const QString &typeName); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     void setDeleteHeldInstance(bool deleteInstance); | 
					
						
							|  |  |  |     bool deleteHeldInstance() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void updateAnchors(); | 
					
						
							|  |  |  |     virtual void paintUpdate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void activateState(); | 
					
						
							|  |  |  |     virtual void deactivateState(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void populateResetHashes(); | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     bool hasValidResetBinding(const PropertyName &propertyName) const; | 
					
						
							|  |  |  |     QQmlAbstractBinding *resetBinding(const PropertyName &propertyName) const; | 
					
						
							|  |  |  |     QVariant resetValue(const PropertyName &propertyName) const; | 
					
						
							|  |  |  |     void setResetValue(const PropertyName &propertyName, const QVariant &value); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QObject *object() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual bool hasContent() const; | 
					
						
							|  |  |  |     virtual bool isResizable() const; | 
					
						
							|  |  |  |     virtual bool isMovable() const; | 
					
						
							|  |  |  |     bool isInPositioner() const; | 
					
						
							|  |  |  |     void setInPositioner(bool isInPositioner); | 
					
						
							|  |  |  |     virtual void refreshPositioner(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     bool hasBindingForProperty(const PropertyName &name, bool *hasChanged = 0) const; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QQmlContext *context() const; | 
					
						
							|  |  |  |     QQmlEngine *engine() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     virtual bool updateStateVariant(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &value); | 
					
						
							|  |  |  |     virtual bool updateStateBinding(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QString &expression); | 
					
						
							|  |  |  |     virtual bool resetStateProperty(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &resetValue); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool isValid() const; | 
					
						
							|  |  |  |     bool isRootNodeInstance() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void doComponentComplete(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual QList<ServerNodeInstance> stateInstances() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void setNodeSource(const QString &source); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static QVariant fixResourcePaths(const QVariant &value); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-15 13:28:48 +02:00
										 |  |  |     virtual void updateDirtyNodeRecursive(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     void doResetProperty(const PropertyName &propertyName); | 
					
						
							|  |  |  |     void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty); | 
					
						
							|  |  |  |     void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty); | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     void deleteObjectsInList(const QQmlProperty &metaProperty); | 
					
						
							|  |  |  |     QVariant convertSpecialCharacter(const QVariant& value) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     QHash<PropertyName, QVariant> m_resetValueHash; | 
					
						
							|  |  |  |     QHash<PropertyName, QWeakPointer<QQmlAbstractBinding> > m_resetBindingHash; | 
					
						
							|  |  |  |     QHash<PropertyName, ServerNodeInstance> m_modelAbstractPropertyHash; | 
					
						
							|  |  |  |     mutable QHash<PropertyName, bool> m_hasBindingHash; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     QString m_id; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-04 17:44:48 +02:00
										 |  |  |     QPointer<NodeInstanceServer> m_nodeInstanceServer; | 
					
						
							| 
									
										
										
										
											2013-03-05 12:19:19 +01:00
										 |  |  |     PropertyName m_parentProperty; | 
					
						
							| 
									
										
										
										
											2013-02-19 11:40:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-04 17:44:48 +02:00
										 |  |  |     QPointer<QObject> m_object; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     NodeInstanceMetaObject *m_metaObject; | 
					
						
							| 
									
										
										
										
											2013-02-19 11:40:16 +01:00
										 |  |  |     qint32 m_instanceId; | 
					
						
							|  |  |  |     bool m_deleteHeldInstance; | 
					
						
							| 
									
										
										
										
											2012-09-19 15:57:22 +02:00
										 |  |  |     bool m_isInPositioner; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace QmlDesigner
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 12:40:44 +01:00
										 |  |  | #endif // OBJECTNODEINSTANCE_H
 |