1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include <qmldesignercorelib_global.h> 29 #include "qmlmodelnodefacade.h" 30 #include "qmlstate.h" 31 #include "qmltimeline.h" 32 #include "qmlchangeset.h" 33 34 #include <nodeinstance.h> 35 36 namespace QmlDesigner { 37 38 class QmlItemNode; 39 class QmlPropertyChanges; 40 class MoveManipulator; 41 class QmlVisualNode; 42 43 class QMLDESIGNERCORE_EXPORT QmlObjectNode : public QmlModelNodeFacade 44 { 45 friend QmlItemNode; 46 friend MoveManipulator; 47 48 public: 49 QmlObjectNode(); 50 QmlObjectNode(const ModelNode &modelNode); 51 52 static bool isValidQmlObjectNode(const ModelNode &modelNode); 53 bool isValid() const override; 54 55 bool hasError() const; 56 QString error() const; 57 bool hasNodeParent() const; 58 bool hasInstanceParent() const; 59 bool hasInstanceParentItem() const; 60 void setParentProperty(const NodeAbstractProperty &parentProeprty); 61 QmlObjectNode instanceParent() const; 62 QmlItemNode instanceParentItem() const; 63 64 QmlItemNode modelParentItem() const; 65 66 void setId(const QString &id); 67 QString id() const; 68 QString validId(); 69 70 QmlModelState currentState() const; 71 QmlTimeline currentTimeline() const; 72 virtual void setVariantProperty(const PropertyName &name, const QVariant &value); 73 virtual void setBindingProperty(const PropertyName &name, const QString &expression); 74 NodeAbstractProperty nodeAbstractProperty(const PropertyName &name) const; 75 NodeAbstractProperty defaultNodeAbstractProperty() const; 76 NodeProperty nodeProperty(const PropertyName &name) const; 77 NodeListProperty nodeListProperty(const PropertyName &name) const; 78 79 bool instanceHasValue(const PropertyName &name) const; 80 QVariant instanceValue(const PropertyName &name) const; 81 TypeName instanceType(const PropertyName &name) const; 82 83 bool hasProperty(const PropertyName &name) const; 84 bool hasBindingProperty(const PropertyName &name) const; 85 bool instanceHasBinding(const PropertyName &name) const; 86 bool propertyAffectedByCurrentState(const PropertyName &name) const; 87 QVariant modelValue(const PropertyName &name) const; 88 bool isTranslatableText(const PropertyName &name) const; 89 QString stripedTranslatableText(const PropertyName &name) const; 90 QString expression(const PropertyName &name) const; 91 bool isInBaseState() const; 92 bool timelineIsActive() const; 93 QmlPropertyChanges propertyChangeForCurrentState() const; 94 95 virtual bool instanceCanReparent() const; 96 97 bool isRootModelNode() const; 98 99 void destroy(); 100 101 void ensureAliasExport(); 102 bool isAliasExported() const; 103 104 QList<QmlModelState> allAffectingStates() const; 105 QList<QmlModelStateOperation> allAffectingStatesOperations() const; 106 107 void removeProperty(const PropertyName &name); 108 109 void setParent(const QmlObjectNode &newParent); 110 111 QmlItemNode toQmlItemNode() const; 112 QmlVisualNode toQmlVisualNode() const; 113 114 bool isAncestorOf(const QmlObjectNode &objectNode) const; 115 116 bool hasDefaultPropertyName() const; 117 PropertyName defaultPropertyName() const; 118 119 static QVariant instanceValue(const ModelNode &modelNode, const PropertyName &name); 120 121 static QString generateTranslatableText(const QString& text); 122 QString simplifiedTypeName() const; 123 124 QStringList allStateNames() const; 125 126 static QmlObjectNode *getQmlObjectNodeOfCorrectType(const ModelNode &modelNode); 127 128 virtual bool isBlocked(const PropertyName &propName) const; 129 130 protected: 131 NodeInstance nodeInstance() const; 132 QmlObjectNode nodeForInstance(const NodeInstance &instance) const; 133 QmlItemNode itemForInstance(const NodeInstance &instance) const; 134 135 protected: 136 QList<QmlModelState> allDefinedStates() const; 137 }; 138 139 QMLDESIGNERCORE_EXPORT uint qHash(const QmlObjectNode &node); 140 QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(const QList<QmlObjectNode> &fxObjectNodeList); 141 QMLDESIGNERCORE_EXPORT QList<QmlObjectNode> toQmlObjectNodeList(const QList<ModelNode> &modelNodeList); 142 }// QmlDesigner 143