/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. ** ** 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 The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ****************************************************************************/ #pragma once #include "qmldesignercorelib_global.h" #include "abstractview.h" #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE class QDeclarativeEngine; class QGraphicsView; class QFileSystemWatcher; class QPainter; QT_END_NAMESPACE namespace ProjectExplorer { class Kit; class Project; } namespace QmlDesigner { class NodeInstanceServerProxy; class CreateSceneCommand; class CreateInstancesCommand; class ClearSceneCommand; class ReparentInstancesCommand; class Change3DViewCommand; class ChangeFileUrlCommand; class ChangeValuesCommand; class ChangeBindingsCommand; class ChangeIdsCommand; class RemoveInstancesCommand; class ChangeSelectionCommand; class RemovePropertiesCommand; class CompleteComponentCommand; class InformationContainer; class TokenCommand; class QMLDESIGNERCORE_EXPORT NodeInstanceView : public AbstractView, public NodeInstanceClientInterface { Q_OBJECT friend class NodeInstance; public: using Pointer = QWeakPointer; explicit NodeInstanceView(QObject *parent = nullptr, NodeInstanceServerInterface::RunModus runModus = NodeInstanceServerInterface::NormalModus); ~NodeInstanceView() override; void modelAttached(Model *model) override; void modelAboutToBeDetached(Model *model) override; void nodeCreated(const ModelNode &createdNode) override; void nodeAboutToBeRemoved(const ModelNode &removedNode) override; void propertiesAboutToBeRemoved(const QList& propertyList) override; void variantPropertiesChanged(const QList& propertyList, PropertyChangeFlags propertyChange) override; void bindingPropertiesChanged(const QList& propertyList, PropertyChangeFlags propertyChange) override; void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) override; void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override; void nodeTypeChanged(const ModelNode& node, const TypeName &type, int majorVersion, int minorVersion) override; void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl) override; void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) override; void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex) override; void importsChanged(const QList &addedImports, const QList &removedImports) override; void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) override; void customNotification(const AbstractView *view, const QString &identifier, const QList &nodeList, const QList &data) override; void nodeSourceChanged(const ModelNode &modelNode, const QString &newNodeSource) override; void currentStateChanged(const ModelNode &node) override; QList instances() const; NodeInstance instanceForModelNode(const ModelNode &node) const ; bool hasInstanceForModelNode(const ModelNode &node) const; NodeInstance instanceForId(qint32 id); bool hasInstanceForId(qint32 id); QRectF sceneRect() const; NodeInstance activeStateInstance() const; void updateChildren(const NodeAbstractProperty &newPropertyParent); void updatePosition(const QList& propertyList); void valuesChanged(const ValuesChangedCommand &command) override; void valuesModified(const ValuesModifiedCommand &command) override; void pixmapChanged(const PixmapChangedCommand &command) override; void informationChanged(const InformationChangedCommand &command) override; void childrenChanged(const ChildrenChangedCommand &command) override; void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) override; void componentCompleted(const ComponentCompletedCommand &command) override; void token(const TokenCommand &command) override; void debugOutput(const DebugOutputCommand &command) override; QImage statePreviewImage(const ModelNode &stateNode) const; void setKit(ProjectExplorer::Kit *kit); void setProject(ProjectExplorer::Project *project); void sendToken(const QString &token, int number, const QVector &nodeVector); void selectionChanged(const ChangeSelectionCommand &command) override; void library3DItemDropped(const Drop3DLibraryItemCommand &command) override; void selectedNodesChanged(const QList &selectedNodeList, const QList &lastSelectedNodeList) override; void show3DView(const QRect &rect); void move3DView(const QPoint &position); void hide3DView(); protected: void timerEvent(QTimerEvent *event) override; private: // functions enum ViewAction { Show, Move, Hide }; void activateState(const NodeInstance &instance); void activateBaseState(); NodeInstance rootNodeInstance() const; NodeInstance loadNode(const ModelNode &node); void removeAllInstanceNodeRelationships(); void removeRecursiveChildRelationship(const ModelNode &removedNode); void insertInstanceRelationships(const NodeInstance &instance); void removeInstanceNodeRelationship(const ModelNode &node); void removeInstanceAndSubInstances(const ModelNode &node); void setStateInstance(const NodeInstance &stateInstance); void clearStateInstance(); NodeInstanceServerInterface *nodeInstanceServer() const; QMultiHash informationChanged(const QVector &containerVector); CreateSceneCommand createCreateSceneCommand(); Change3DViewCommand createChange3DViewCommand(ViewAction action, const QPoint &pos = {}, const QSize &size = {}) const; ClearSceneCommand createClearSceneCommand() const; CreateInstancesCommand createCreateInstancesCommand(const QList &instanceList) const; CompleteComponentCommand createComponentCompleteCommand(const QList &instanceList) const; ComponentCompletedCommand createComponentCompletedCommand(const QList &instanceList) const; ReparentInstancesCommand createReparentInstancesCommand(const QList &instanceList) const; ReparentInstancesCommand createReparentInstancesCommand(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent) const; ChangeFileUrlCommand createChangeFileUrlCommand(const QUrl &fileUrl) const; ChangeValuesCommand createChangeValueCommand(const QList &propertyList) const; ChangeBindingsCommand createChangeBindingCommand(const QList &propertyList) const; ChangeIdsCommand createChangeIdsCommand(const QList &instanceList) const; RemoveInstancesCommand createRemoveInstancesCommand(const QList &nodeList) const; ChangeSelectionCommand createChangeSelectionCommand(const QList &nodeList) const; RemoveInstancesCommand createRemoveInstancesCommand(const ModelNode &node) const; RemovePropertiesCommand createRemovePropertiesCommand(const QList &propertyList) const; RemoveSharedMemoryCommand createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, quint32 keyNumber); RemoveSharedMemoryCommand createRemoveSharedMemoryCommand(const QString &sharedMemoryTypeName, const QList &nodeList); void resetHorizontalAnchors(const ModelNode &node); void resetVerticalAnchors(const ModelNode &node); void restartProcess(); void delayedRestartProcess(); private: void handleCrash(); void startPuppetTransaction(); void endPuppetTransaction(); private: //variables NodeInstance m_rootNodeInstance; NodeInstance m_activeStateInstance; QHash m_nodeInstanceHash; QHash m_statePreviewImage; QPointer m_nodeInstanceServer; QImage m_baseStatePreviewImage; QElapsedTimer m_lastCrashTime; NodeInstanceServerInterface::RunModus m_runModus; ProjectExplorer::Kit *m_currentKit = nullptr; ProjectExplorer::Project *m_currentProject = nullptr; int m_restartProcessTimerId; RewriterTransaction m_puppetTransaction; }; } // namespace ProxyNodeInstanceView