OSDN Git Service

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