OSDN Git Service

461f6dc778ee43e041f7c396407f1633a2c2cb8e
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / designercore / include / abstractview.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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef ABSTRACTVIEW_H
35 #define ABSTRACTVIEW_H
36
37 #include <corelib_global.h>
38
39 #include <model.h>
40 #include <modelnode.h>
41 #include <abstractproperty.h>
42 #include <rewritertransaction.h>
43
44 #include <QObject>
45
46 QT_BEGIN_NAMESPACE
47 class QStyle;
48 QT_END_NAMESPACE
49
50 namespace QmlDesigner {
51     namespace Internal {
52         class InternalNode;
53         typedef QSharedPointer<InternalNode> InternalNodePointer;
54         typedef QWeakPointer<InternalNode> InternalNodeWeakPointer;
55     }
56 }
57
58 namespace QmlDesigner {
59
60 class QmlModelView;
61 class NodeInstanceView;
62 class RewriterView;
63
64 class CORESHARED_EXPORT AbstractView : public QObject
65 {
66     Q_OBJECT
67 public:
68     Q_FLAGS(PropertyChangeFlag PropertyChangeFlags)
69     typedef QWeakPointer<AbstractView> Pointer;
70
71     enum PropertyChangeFlag {
72       NoAdditionalChanges = 0x0,
73       PropertiesAdded = 0x1,
74       EmptyPropertiesRemoved = 0x2
75     };
76     Q_DECLARE_FLAGS(PropertyChangeFlags, PropertyChangeFlag)
77     AbstractView(QObject *parent = 0)
78             : QObject(parent) {}
79
80     virtual ~AbstractView();
81
82     Model* model() const;
83
84     RewriterTransaction beginRewriterTransaction();
85
86     ModelNode createModelNode(const QString &typeString,
87                          int majorVersion,
88                          int minorVersion,
89                          const PropertyListType &propertyList = PropertyListType());
90
91     const ModelNode rootModelNode() const;
92     ModelNode rootModelNode();
93
94     void setSelectedModelNodes(const QList<ModelNode> &selectedNodeList);
95     void selectModelNode(const ModelNode &node);
96     void deselectModelNode(const ModelNode &node);
97     void clearSelectedModelNodes();
98
99     QList<ModelNode> selectedModelNodes() const;
100
101     ModelNode modelNodeForId(const QString &id);
102     bool hasId(const QString &id) const;
103
104     ModelNode modelNodeForInternalId(qint32 internalId);
105     bool hasModelNodeForInternalId(qint32 internalId) const;
106
107     QList<ModelNode> allModelNodes();
108
109     void emitCustomNotification(const QString &identifier);
110     void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList);
111     void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
112
113     void emitInstancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
114     void emitInstancesCompleted(const QVector<ModelNode> &nodeList);
115     void emitInstanceInformationsChange(const QVector<ModelNode> &nodeList);
116     void emitInstancesRenderImageChanged(const QVector<ModelNode> &nodeList);
117     void emitInstancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
118     void emitInstancesChildrenChanged(const QVector<ModelNode> &nodeList);
119     void emitRewriterBeginTransaction();
120     void emitRewriterEndTransaction();
121     void emitActualStateChanged(const ModelNode &node);
122
123     virtual void modelAttached(Model *model);
124     virtual void modelAboutToBeDetached(Model *model);
125
126     virtual void nodeCreated(const ModelNode &createdNode) = 0;
127     virtual void nodeAboutToBeRemoved(const ModelNode &removedNode) = 0;
128     virtual void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange) = 0;
129     virtual void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) = 0;
130     virtual void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) = 0;
131     virtual void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) = 0;
132     virtual void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList) = 0;
133     virtual void propertiesRemoved(const QList<AbstractProperty>& propertyList) = 0;
134     virtual void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange) = 0;
135     virtual void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) = 0;
136     virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) = 0;
137
138     virtual void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList) = 0;
139     virtual void instancesCompleted(const QVector<ModelNode> &completedNodeList) = 0;
140     virtual void instanceInformationsChange(const QVector<ModelNode> &nodeList) = 0;
141     virtual void instancesRenderImageChanged(const QVector<ModelNode> &nodeList) = 0;
142     virtual void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList) = 0;
143     virtual void instancesChildrenChanged(const QVector<ModelNode> &nodeList) = 0;
144
145     virtual void rewriterBeginTransaction() = 0;
146     virtual void rewriterEndTransaction() = 0;
147
148     virtual void actualStateChanged(const ModelNode &node) = 0; // base state is a invalid model node
149
150     virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
151                                       const QList<ModelNode> &lastSelectedNodeList) = 0;
152
153     virtual void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);
154
155     virtual void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) = 0;
156
157     virtual void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) = 0;
158
159     virtual void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
160
161     virtual void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);
162
163     virtual void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) = 0;
164
165     QmlModelView *toQmlModelView();
166
167     void changeRootNodeType(const QString &type, int majorVersion, int minorVersion);
168
169     NodeInstanceView *nodeInstanceView() const;
170     RewriterView *rewriterView() const;
171
172 protected:
173     void setModel(Model * model);
174     void removeModel();
175
176 private: //functions
177     QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList) const;
178
179
180 private:
181     QWeakPointer<Model> m_model;
182 };
183
184 CORESHARED_EXPORT QList<Internal::InternalNodePointer> toInternalNodeList(const QList<ModelNode> &nodeList);
185 CORESHARED_EXPORT QList<ModelNode> toModelNodeList(const QList<Internal::InternalNodePointer> &nodeList, AbstractView *view);
186
187 }
188
189 #endif // ABSTRACTVIEW_H