OSDN Git Service

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