OSDN Git Service

d6676c851f6a4370e45e7c25af2e395a344bec3f
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / formeditor / formeditorview.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 info@qt.nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef FORMEDITORVIEW_H
34 #define FORMEDITORVIEW_H
35
36 #include <qmlmodelview.h>
37
38 QT_BEGIN_NAMESPACE
39 class QGraphicsScene;
40 class QGraphicsSceneMouseEvent;
41 QT_END_NAMESPACE
42
43 namespace QmlDesigner {
44
45 class FormEditorWidget;
46 class FormEditorNodeInstanceView;
47 class FormEditorScene;
48 class NodeInstanceView;
49
50 class AbstractFormEditorTool;
51 class MoveTool;
52 class SelectionTool;
53 class ResizeTool;
54 class AnchorTool;
55 class DragTool;
56 class ItemLibraryEntry;
57 class QmlItemNode;
58
59 class  FormEditorView : public QmlModelView
60 {
61     Q_OBJECT
62
63 public:
64     FormEditorView(QObject *parent);
65     ~FormEditorView();
66
67     // AbstractView
68     void modelAttached(Model *model);
69     void modelAboutToBeDetached(Model *model);
70
71     void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports);
72
73     void nodeCreated(const ModelNode &createdNode);
74     void nodeAboutToBeRemoved(const ModelNode &removedNode);
75     void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
76     void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
77     void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList);
78     void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
79     void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
80     void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
81
82     void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
83                               const QList<ModelNode> &lastSelectedNodeList);
84     void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
85     void propertiesRemoved(const QList<AbstractProperty> &propertyList);
86
87     // FormEditorView
88     FormEditorWidget *widget() const;
89     AbstractFormEditorTool *currentTool() const;
90     FormEditorScene *scene() const;
91
92     bool changeToMoveTool();
93     bool changeToMoveTool(const QPointF &beginPoint);
94     void changeToDragTool();
95     void changeToSelectionTool();
96     void changeToSelectionTool(QGraphicsSceneMouseEvent *event);
97     void changeToResizeTool();
98     void changeToAnchorTool();
99     void changeToTransformTools();
100
101     void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
102     void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
103
104     void instancesCompleted(const QVector<ModelNode> &completedNodeList);
105     void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
106     void instancesRenderImageChanged(const QVector<ModelNode> &nodeList);
107     void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
108     void instancesChildrenChanged(const QVector<ModelNode> &nodeList);
109     void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
110     void instancesToken(const QString &tokenName, int tokenNumber, const QVector<ModelNode> &nodeVector);
111
112     void rewriterBeginTransaction();
113     void rewriterEndTransaction();
114
115     double margins() const;
116     double spacing() const;
117     void deActivateItemCreator();
118
119     void actualStateChanged(const ModelNode &node);
120
121 protected:
122     void reset();
123
124 protected slots:
125     void delayedReset();
126     QList<ModelNode> adjustStatesForModelNodes(const QList<ModelNode> &nodeList) const;
127     void updateGraphicsIndicators();
128     void setSelectOnlyContentItemsAction(bool selectOnlyContentItems);
129     bool isMoveToolAvailable() const;
130
131 private: //functions
132     void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
133     void removeNodeFromScene(const QmlItemNode &qmlItemNode);
134     void hideNodeFromScene(const QmlItemNode &qmlItemNode);
135
136 private: //variables
137     QWeakPointer<FormEditorWidget> m_formEditorWidget;
138     QWeakPointer<FormEditorScene> m_scene;
139     MoveTool *m_moveTool;
140     SelectionTool *m_selectionTool;
141     ResizeTool *m_resizeTool;
142     AnchorTool *m_anchorTool;
143     DragTool *m_dragTool;
144     AbstractFormEditorTool *m_currentTool;
145     int m_transactionCounter;
146 };
147
148 }
149
150 #endif //FORMEDITORVIEW_H