1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef NODEINSTANCEVIEW_H
35 #define NODEINSTANCEVIEW_H
37 #include "corelib_global.h"
38 #include "abstractview.h"
40 #include <modelnode.h>
41 #include <nodeinstance.h>
42 #include <nodeinstanceclientinterface.h>
43 #include <nodeinstanceserverinterface.h>
48 #include <QWeakPointer>
53 class QDeclarativeEngine;
55 class QFileSystemWatcher;
59 namespace QmlDesigner {
61 class NodeInstanceServerInterface;
62 class CreateSceneCommand;
63 class CreateInstancesCommand;
64 class ClearSceneCommand;
65 class ReparentInstancesCommand;
66 class ChangeFileUrlCommand;
67 class ChangeValuesCommand;
68 class ChangeBindingsCommand;
69 class ChangeIdsCommand;
70 class RemoveInstancesCommand;
71 class RemovePropertiesCommand;
72 class AddImportCommand;
73 class CompleteComponentCommand;
75 class CORESHARED_EXPORT NodeInstanceView : public AbstractView, public NodeInstanceClientInterface
79 friend class NodeInstance;
82 typedef QWeakPointer<NodeInstanceView> Pointer;
84 explicit NodeInstanceView(QObject *parent = 0, NodeInstanceServerInterface::RunModus runModus = NodeInstanceServerInterface::NormalModus);
87 void modelAttached(Model *model);
88 void modelAboutToBeDetached(Model *model);
89 void nodeCreated(const ModelNode &createdNode);
90 void nodeAboutToBeRemoved(const ModelNode &removedNode);
91 void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
92 void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList);
93 void propertiesRemoved(const QList<AbstractProperty>& propertyList);
94 void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
95 void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
96 void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
97 void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
98 void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
99 void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
100 void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
101 void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
102 void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList);
103 void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
104 void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
105 void instancesCompleted(const QVector<ModelNode> &completedNodeList);
106 void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports);
107 void instanceInformationsChange(const QVector<ModelNode> &nodeList);
108 void instancesRenderImageChanged(const QVector<ModelNode> &nodeList);
109 void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
110 void instancesChildrenChanged(const QVector<ModelNode> &nodeList);
111 void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
112 void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
114 void rewriterBeginTransaction();
115 void rewriterEndTransaction();
117 void actualStateChanged(const ModelNode &node);
119 QList<NodeInstance> instances() const;
120 NodeInstance instanceForNode(const ModelNode &node) const ;
121 bool hasInstanceForNode(const ModelNode &node) const;
123 NodeInstance instanceForId(qint32 id);
124 bool hasInstanceForId(qint32 id);
126 QRectF sceneRect() const;
128 NodeInstance activeStateInstance() const;
130 void activateState(const NodeInstance &instance);
131 void activateBaseState();
133 void valuesChanged(const ValuesChangedCommand &command);
134 void pixmapChanged(const PixmapChangedCommand &command);
135 void informationChanged(const InformationChangedCommand &command);
136 void childrenChanged(const ChildrenChangedCommand &command);
137 void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command);
138 void componentCompleted(const ComponentCompletedCommand &command);
140 QImage statePreviewImage(const ModelNode &stateNode) const;
142 private: // functions
143 NodeInstance rootNodeInstance() const;
145 NodeInstance loadNode(const ModelNode &node);
147 void removeAllInstanceNodeRelationships();
149 void removeRecursiveChildRelationship(const ModelNode &removedNode);
151 void insertInstanceRelationships(const NodeInstance &instance);
152 void removeInstanceNodeRelationship(const ModelNode &node);
154 void removeInstanceAndSubInstances(const ModelNode &node);
156 void setStateInstance(const NodeInstance &stateInstance);
157 void clearStateInstance();
159 NodeInstanceServerInterface *nodeInstanceServer() const;
161 CreateSceneCommand createCreateSceneCommand();
162 ClearSceneCommand createClearSceneCommand() const;
163 CreateInstancesCommand createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const;
164 CompleteComponentCommand createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const;
165 ComponentCompletedCommand createComponentCompletedCommand(const QList<NodeInstance> &instanceList) const;
166 ReparentInstancesCommand createReparentInstancesCommand(const QList<NodeInstance> &instanceList) const;
167 ReparentInstancesCommand createReparentInstancesCommand(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent) const;
168 ChangeFileUrlCommand createChangeFileUrlCommand(const QUrl &fileUrl) const;
169 ChangeValuesCommand createChangeValueCommand(const QList<VariantProperty> &propertyList) const;
170 ChangeBindingsCommand createChangeBindingCommand(const QList<BindingProperty> &propertyList) const;
171 ChangeIdsCommand createChangeIdsCommand(const QList<NodeInstance> &instanceList) const;
172 RemoveInstancesCommand createRemoveInstancesCommand(const QList<ModelNode> &nodeList) const;
173 RemoveInstancesCommand createRemoveInstancesCommand(const ModelNode &node) const;
174 RemovePropertiesCommand createRemovePropertiesCommand(const QList<AbstractProperty> &propertyList) const;
175 AddImportCommand createImportCommand(const Import &import);
177 void resetHorizontalAnchors(const ModelNode &node);
178 void resetVerticalAnchors(const ModelNode &node);
180 void restartProcess();
186 NodeInstance m_rootNodeInstance;
187 NodeInstance m_activeStateInstance;
189 QHash<ModelNode, NodeInstance> m_nodeInstanceHash;
190 QHash<ModelNode, QImage> m_statePreviewImage;
193 QWeakPointer<NodeInstanceServerInterface> m_nodeInstanceServer;
194 QImage m_baseStatePreviewImage;
195 QTime m_lastCrashTime;
196 NodeInstanceServerInterface::RunModus m_runModus;
199 } // namespace ProxyNodeInstanceView
201 #endif // NODEINSTANCEVIEW_H