componentview.h 5.34 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
** 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.
23
**
hjk's avatar
hjk committed
24 25
** 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 35 36 37

#ifndef COMPONENTVIEW_H
#define COMPONENTVIEW_H

#include <abstractview.h>
#include <modelnode.h>

#include <QStringList>

38
QT_BEGIN_NAMESPACE
39
class QStandardItemModel;
Marco Bubke's avatar
Marco Bubke committed
40
class QComboBox;
41
QT_END_NAMESPACE
42 43 44

namespace QmlDesigner {

45 46
class ComponentAction;

47 48 49 50 51 52 53 54 55 56
class ComponentView : public AbstractView
{
    Q_OBJECT

public:
    enum UserRoles
    {
        ModelNodeRole = Qt::UserRole
    };

Marco Bubke's avatar
Marco Bubke committed
57
    ComponentView(QObject *parent = 0);
58 59 60 61

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

62 63
    ComponentAction *action();

64 65 66
    void nodeCreated(const ModelNode &createdNode);
    void nodeAboutToBeRemoved(const ModelNode &removedNode);
    void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
67
    void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
68 69 70 71 72 73
    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 propertiesRemoved(const QList<AbstractProperty>& propertyList);
    void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange);
    void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange);
74
    void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
Marco Bubke's avatar
Marco Bubke committed
75
    void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
76
    void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList);
77
    void instancesCompleted(const QVector<ModelNode> &completedNodeList);
78
    void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &/*informationChangeHash*/);
79 80 81
    void instancesRenderImageChanged(const QVector<ModelNode> &nodeList);
    void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList);
    void instancesChildrenChanged(const QVector<ModelNode> &nodeList);
82 83
    void instancesToken(const QString &tokenName, int tokenNumber, const QVector<ModelNode> &nodeVector);

84
    void nodeSourceChanged(const ModelNode &modelNode, const QString &newNodeSource);
85 86 87

    void rewriterBeginTransaction();
    void rewriterEndTransaction();
88

89 90
    void actualStateChanged(const ModelNode &node);

91 92 93 94 95
    void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
                                      const QList<ModelNode> &lastSelectedNodeList);

    void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl);

96
    void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
97

98
    void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data);
99 100 101

    void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data);

102
    void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports);
103 104 105 106 107

    QStandardItemModel *standardItemModel() const;

    ModelNode modelNode(int index) const;

108 109
    void setComponentNode(const ModelNode &node);

Marco Bubke's avatar
Marco Bubke committed
110 111
    QWidget *widget();

112 113 114 115 116 117
signals:
    void componentListChanged(const QStringList &componentList);

private: //functions
    void updateModel();
    void searchForComponentAndAddToList(const ModelNode &node);
118
    void searchForComponentAndRemoveFromList(const ModelNode &node);
119
    void removeSingleNodeFromList(const ModelNode &node);
120
    int indexForNode(const ModelNode &node);
121 122 123

private:
    QStandardItemModel *m_standardItemModel;
124
    ComponentAction *m_componentAction;
125 126 127 128 129
};

} // namespace QmlDesigner

#endif // COMPONENTVIEW_H