formeditorview.h 6.32 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
namespace QmlDesigner {

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

class AbstractFormEditorTool;
52
class AbstractCustomTool;
53 54 55 56
class MoveTool;
class SelectionTool;
class ResizeTool;
class DragTool;
57
class ItemLibraryEntry;
58 59
class QmlItemNode;

Thomas Hartmann's avatar
Thomas Hartmann committed
60
class QMLDESIGNERCORE_EXPORT FormEditorView : public QmlModelView
61 62 63 64
{
    Q_OBJECT

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

    // AbstractView
69 70
    void modelAttached(Model *model) QTC_OVERRIDE;
    void modelAboutToBeDetached(Model *model) QTC_OVERRIDE;
71

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

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

    void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
85 86 87
                              const QList<ModelNode> &lastSelectedNodeList) QTC_OVERRIDE;
    void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) QTC_OVERRIDE;
    void propertiesRemoved(const QList<AbstractProperty> &propertyList) QTC_OVERRIDE;
88 89

    // FormEditorView
90
    WidgetInfo widgetInfo() QTC_OVERRIDE;
91

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

96 97
    bool changeToMoveTool();
    bool changeToMoveTool(const QPointF &beginPoint);
98 99 100 101 102
    void changeToDragTool();
    void changeToSelectionTool();
    void changeToSelectionTool(QGraphicsSceneMouseEvent *event);
    void changeToResizeTool();
    void changeToTransformTools();
103
    void changeToCustomTool(const ModelNode &modelNode);
104
    void changeToCustomTool(AbstractCustomTool *customTool);
105

106
    void registerTool(AbstractCustomTool *tool);
107

108
    void nodeSlidedToIndex(const NodeListProperty &listProperty, int newIndex, int oldIndex);
109
    void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) QTC_OVERRIDE;
110

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

119 120
    void rewriterBeginTransaction() QTC_OVERRIDE;
    void rewriterEndTransaction() QTC_OVERRIDE;
121

122 123 124 125
    double margins() const;
    double spacing() const;
    void deActivateItemCreator();

126
    void actualStateChanged(const ModelNode &node) QTC_OVERRIDE;
Thomas Hartmann's avatar
Thomas Hartmann committed
127

128
protected:
129
    void reset();
130 131

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

private: //functions
    void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
140 141
    void removeNodeFromScene(const QmlItemNode &qmlItemNode);
    void hideNodeFromScene(const QmlItemNode &qmlItemNode);
142 143 144 145

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

}

#endif //FORMEDITORVIEW_H