formeditorview.h 5.71 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29
30
31
32
33
34

#ifndef FORMEDITORVIEW_H
#define FORMEDITORVIEW_H

#include <qmlmodelview.h>

35
QT_BEGIN_NAMESPACE
36
37
class QGraphicsScene;
class QGraphicsSceneMouseEvent;
38
QT_END_NAMESPACE
39

Thomas Hartmann's avatar
Thomas Hartmann committed
40
41
42
43
namespace Utils {
class CrumblePath;
}

44
45
46
47
48
49
50
51
52
53
54
55
namespace QmlDesigner {

class FormEditorWidget;
class FormEditorNodeInstanceView;
class FormEditorScene;
class NodeInstanceView;

class AbstractFormEditorTool;
class MoveTool;
class SelectionTool;
class ResizeTool;
class DragTool;
56
class ItemLibraryEntry;
57
58
59
60
61
62
63
class QmlItemNode;

class  FormEditorView : public QmlModelView
{
    Q_OBJECT

public:
Marco Bubke's avatar
Marco Bubke committed
64
    FormEditorView(QObject *parent = 0);
65
66
67
68
69
70
    ~FormEditorView();

    // AbstractView
    void modelAttached(Model *model);
    void modelAboutToBeDetached(Model *model);

71
    void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports);
72

73
74
75
76
77
78
79
    void nodeCreated(const ModelNode &createdNode);
    void nodeAboutToBeRemoved(const ModelNode &removedNode);
    void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
    void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
    void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList);
    void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
    void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
80
    void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
81
82
83

    void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
                              const QList<ModelNode> &lastSelectedNodeList);
Marco Bubke's avatar
Marco Bubke committed
84
    void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
85
    void propertiesRemoved(const QList<AbstractProperty> &propertyList);
86
87

    // FormEditorView
Marco Bubke's avatar
Marco Bubke committed
88
    QWidget *widget();
89
90
    WidgetInfo widgetInfo();

Marco Bubke's avatar
Marco Bubke committed
91
    FormEditorWidget *formEditorWidget();
92
93
94
    AbstractFormEditorTool *currentTool() const;
    FormEditorScene *scene() const;

95
96
    bool changeToMoveTool();
    bool changeToMoveTool(const QPointF &beginPoint);
97
98
99
100
101
102
    void changeToDragTool();
    void changeToSelectionTool();
    void changeToSelectionTool(QGraphicsSceneMouseEvent *event);
    void changeToResizeTool();
    void changeToTransformTools();

103
104
    void registerTool(AbstractFormEditorTool *tool);

105
    void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
106
    void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data);
107

108
    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
109
    void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash);
110
111
112
    void instancesRenderImageChanged(const QVector<ModelNode> &nodeList);
    void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
    void instancesChildrenChanged(const QVector<ModelNode> &nodeList);
113
    void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
114
    void instancesToken(const QString &tokenName, int tokenNumber, const QVector<ModelNode> &nodeVector);
115
116
117

    void rewriterBeginTransaction();
    void rewriterEndTransaction();
118

119
120
121
122
    double margins() const;
    double spacing() const;
    void deActivateItemCreator();

Thomas Hartmann's avatar
Thomas Hartmann committed
123
124
    void actualStateChanged(const ModelNode &node);

125
protected:
126
    void reset();
127
128

protected slots:
129
    void delayedReset();
130
131
    QList<ModelNode> adjustStatesForModelNodes(const QList<ModelNode> &nodeList) const;
    void updateGraphicsIndicators();
132
    void setSelectOnlyContentItemsAction(bool selectOnlyContentItems);
133
    bool isMoveToolAvailable() const;
134
135
136

private: //functions
    void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
137
138
    void removeNodeFromScene(const QmlItemNode &qmlItemNode);
    void hideNodeFromScene(const QmlItemNode &qmlItemNode);
139
140
141
142

private: //variables
    QWeakPointer<FormEditorWidget> m_formEditorWidget;
    QWeakPointer<FormEditorScene> m_scene;
143
    QList<AbstractFormEditorTool*> m_toolList;
144
145
146
147
148
    MoveTool *m_moveTool;
    SelectionTool *m_selectionTool;
    ResizeTool *m_resizeTool;
    DragTool *m_dragTool;
    AbstractFormEditorTool *m_currentTool;
149
    int m_transactionCounter;
150
151
152
153
154
};

}

#endif //FORMEDITORVIEW_H