2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2010-01-07 12:14:35 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
#ifndef COMPONENTVIEW_H
|
|
|
|
|
#define COMPONENTVIEW_H
|
|
|
|
|
|
|
|
|
|
#include <abstractview.h>
|
|
|
|
|
#include <modelnode.h>
|
|
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
2010-02-16 15:13:57 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
2010-01-07 12:14:35 +01:00
|
|
|
class QStandardItemModel;
|
2013-01-23 12:31:22 +01:00
|
|
|
class QComboBox;
|
2010-02-16 15:13:57 +01:00
|
|
|
QT_END_NAMESPACE
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
2011-05-24 18:47:33 +02:00
|
|
|
class ComponentAction;
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
class ComponentView : public AbstractView
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum UserRoles
|
|
|
|
|
{
|
|
|
|
|
ModelNodeRole = Qt::UserRole
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-23 12:31:22 +01:00
|
|
|
ComponentView(QObject *parent = 0);
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void modelAttached(Model *model) Q_DECL_OVERRIDE;
|
|
|
|
|
void modelAboutToBeDetached(Model *model) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2011-05-24 18:47:33 +02:00
|
|
|
ComponentAction *action();
|
|
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void nodeCreated(const ModelNode &createdNode) Q_DECL_OVERRIDE;
|
|
|
|
|
void nodeAboutToBeRemoved(const ModelNode &removedNode) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty,
|
2014-09-24 12:49:32 +02:00
|
|
|
PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent,
|
|
|
|
|
const NodeAbstractProperty &oldPropertyParent,
|
2014-09-24 12:49:32 +02:00
|
|
|
AbstractView::PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent,
|
|
|
|
|
const NodeAbstractProperty &oldPropertyParent,
|
2014-09-24 12:49:32 +02:00
|
|
|
AbstractView::PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
|
|
|
|
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) Q_DECL_OVERRIDE;
|
|
|
|
|
void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList) Q_DECL_OVERRIDE;
|
|
|
|
|
void propertiesRemoved(const QList<AbstractProperty>& propertyList) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
void variantPropertiesChanged(const QList<VariantProperty>& propertyList,
|
2014-09-24 12:49:32 +02:00
|
|
|
PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList,
|
2014-09-24 12:49:32 +02:00
|
|
|
PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
2013-04-02 12:27:45 +02:00
|
|
|
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty>& propertyList,
|
2014-09-24 12:49:32 +02:00
|
|
|
PropertyChangeFlags propertyChange) Q_DECL_OVERRIDE;
|
|
|
|
|
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) Q_DECL_OVERRIDE;
|
|
|
|
|
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &propertyList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancesCompleted(const QVector<ModelNode> &completedNodeList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instanceInformationsChange(const QMultiHash<ModelNode, InformationName> &informationChangeHash) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancesRenderImageChanged(const QVector<ModelNode> &nodeList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancesPreviewImageChanged(const QVector<ModelNode> &nodeList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancesChildrenChanged(const QVector<ModelNode> &nodeList) Q_DECL_OVERRIDE;
|
|
|
|
|
void instancesToken(const QString &tokenName, int tokenNumber, const QVector<ModelNode> &nodeVector) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void nodeSourceChanged(const ModelNode &modelNode, const QString &newNodeSource) Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void rewriterBeginTransaction() Q_DECL_OVERRIDE;
|
|
|
|
|
void rewriterEndTransaction() Q_DECL_OVERRIDE;
|
2013-03-08 11:27:23 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void currentStateChanged(const ModelNode &node) Q_DECL_OVERRIDE;
|
2011-02-02 21:52:15 +01:00
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
2014-09-24 12:49:32 +02:00
|
|
|
const QList<ModelNode> &lastSelectedNodeList) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2013-03-08 11:27:23 +01:00
|
|
|
void customNotification(const AbstractView *view, const QString &identifier,
|
2014-09-24 12:49:32 +02:00
|
|
|
const QList<ModelNode> &nodeList, const QList<QVariant> &data) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2014-09-24 12:49:32 +02:00
|
|
|
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) Q_DECL_OVERRIDE;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
QStandardItemModel *standardItemModel() const;
|
|
|
|
|
|
|
|
|
|
ModelNode modelNode(int index) const;
|
|
|
|
|
|
2011-06-27 17:43:44 +02:00
|
|
|
void setComponentNode(const ModelNode &node);
|
2013-09-26 18:46:39 +02:00
|
|
|
void setComponentToMaster();
|
2011-06-27 17:43:44 +02:00
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
signals:
|
|
|
|
|
void componentListChanged(const QStringList &componentList);
|
|
|
|
|
|
|
|
|
|
private: //functions
|
|
|
|
|
void updateModel();
|
|
|
|
|
void searchForComponentAndAddToList(const ModelNode &node);
|
2011-05-24 18:47:33 +02:00
|
|
|
void searchForComponentAndRemoveFromList(const ModelNode &node);
|
2011-06-09 11:34:13 +02:00
|
|
|
void removeSingleNodeFromList(const ModelNode &node);
|
2013-10-16 18:02:31 +02:00
|
|
|
int indexForNode(const ModelNode &node) const;
|
|
|
|
|
int indexOfMaster() const;
|
|
|
|
|
bool hasMasterEntry() const;
|
|
|
|
|
bool hasEntryForNode(const ModelNode &node) const;
|
2013-09-26 18:46:39 +02:00
|
|
|
void addMasterDocument();
|
2013-10-16 18:02:31 +02:00
|
|
|
void removeMasterDocument();
|
|
|
|
|
QString descriptionForNode(const ModelNode &node) const;
|
|
|
|
|
void updateDescription(const ModelNode &node);
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QStandardItemModel *m_standardItemModel;
|
2011-05-24 18:47:33 +02:00
|
|
|
ComponentAction *m_componentAction;
|
2010-01-07 12:14:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlDesigner
|
|
|
|
|
|
|
|
|
|
#endif // COMPONENTVIEW_H
|