diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index 297f32f86a63e2d58a2289f28fb9b5a68a41804e..72a5cabb654026db58a3a08bb845403604d75971 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -162,9 +162,9 @@ void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode) QmlModelView::nodeAboutToBeRemoved(removedNode); } - void FormEditorView::nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) + void FormEditorView::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { - QmlItemNode oldItemNode(node); + QmlItemNode oldItemNode(rootModelNode()); if (oldItemNode.isValid() && m_scene->hasItemForQmlItemNode(oldItemNode)) { FormEditorItem *item = m_scene->itemForQmlItemNode(oldItemNode); @@ -179,9 +179,9 @@ void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode) delete item; } - QmlModelView::nodeTypeChanged(node, type, majorVersion, minorVersion); + QmlModelView::rootNodeTypeChanged(type, majorVersion, minorVersion); - QmlItemNode newItemNode(node); + QmlItemNode newItemNode(rootModelNode()); if (newItemNode.isValid()) //only setup QmlItems setupFormEditorItemTree(newItemNode); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.h b/src/plugins/qmldesigner/components/formeditor/formeditorview.h index bb39e4b1b18e425317a9a9e324dba12591d2938a..974a3c29afa731f0b9e0e85861a9d8c2b418a5a6 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.h +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.h @@ -71,7 +71,7 @@ public: void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); diff --git a/src/plugins/qmldesigner/components/integration/componentview.cpp b/src/plugins/qmldesigner/components/integration/componentview.cpp index 858b8f2fbe42e02d3d6afed7901a69aeafebc8bd..2d24f5c52eb8f0f33bd82142a8c06965d60849e5 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.cpp +++ b/src/plugins/qmldesigner/components/integration/componentview.cpp @@ -158,7 +158,7 @@ void ComponentView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& /* void ComponentView::propertiesRemoved(const QList<AbstractProperty>& /*propertyList*/) {} void ComponentView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {} void ComponentView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, PropertyChangeFlags /*propertyChange*/) {} -void ComponentView::nodeTypeChanged(const ModelNode &/*node*/, const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {} +void ComponentView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) {} diff --git a/src/plugins/qmldesigner/components/integration/componentview.h b/src/plugins/qmldesigner/components/integration/componentview.h index cc02b7124333e62e0a97192c6a0a80c22ec932f6..47c74ff239d5bc144a2bb9359bc6caa70e4cf368 100644 --- a/src/plugins/qmldesigner/components/integration/componentview.h +++ b/src/plugins/qmldesigner/components/integration/componentview.h @@ -63,7 +63,7 @@ public: void propertiesRemoved(const QList<AbstractProperty>& propertyList); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index 210596bfdcf008d3d6b4f4c899f373ca974c450f..c1337013c97575361101df2d2d1f8d21e6129c7a 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -584,7 +584,7 @@ void DesignDocumentController::copySelected() foreach (ModelNode node, view.rootModelNode().allDirectSubModelNodes()) { node.destroy(); } - view.rootModelNode().changeType("Qt/Rectangle", 4, 6); + view.changeRootNodeType("Qt/Rectangle", 4, 6); view.rootModelNode().setId("designer__Selection"); foreach (const ModelNode &selectedNode, selectedNodes) { diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp index dc1fe48b2f7f77a6687e00399da76d3ca80f28c2..22b0410834085a57d174481185f20e6b9d337872 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.cpp @@ -48,7 +48,7 @@ void DesignDocumentControllerView::propertiesAboutToBeRemoved(const QList<Abstra void DesignDocumentControllerView::propertiesRemoved(const QList<AbstractProperty>& /*propertyList*/) {}; void DesignDocumentControllerView::variantPropertiesChanged(const QList<VariantProperty>& /*propertyList*/, AbstractView::PropertyChangeFlags /*propertyChange*/) {}; void DesignDocumentControllerView::bindingPropertiesChanged(const QList<BindingProperty>& /*propertyList*/, AbstractView::PropertyChangeFlags /*propertyChange*/) {}; -void DesignDocumentControllerView::nodeTypeChanged(const ModelNode & /*node*/,const QString & /*type*/, int /*majorVersion*/, int /*minorVersion*/) {}; +void DesignDocumentControllerView::rootNodeTypeChanged(const QString & /*type*/, int /*majorVersion*/, int /*minorVersion*/) {}; void DesignDocumentControllerView::selectedNodesChanged(const QList<ModelNode> & /*selectedNodeList*/, const QList<ModelNode> & /*lastSelectedNodeList*/) {}; diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h index 6000dd093d60439b6e25c34aef3225b3bd5e5ee6..4af5443c6ab28c40ba9487529d988242909aca3e 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontrollerview.h @@ -51,7 +51,7 @@ public: virtual void propertiesRemoved(const QList<AbstractProperty>& propertyList); virtual void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); virtual void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - virtual void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp index fb0d244030f8060e5281f2436c79ef969df79bdd..6e1a5353d987cabab75f41d89cc81138f57b719b 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp @@ -138,11 +138,11 @@ void NavigatorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& pr } } -void NavigatorView::nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) +void NavigatorView::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { - QmlModelView::nodeTypeChanged(node, type, majorVersion, minorVersion); - if (m_treeModel->isInTree(node)) - m_treeModel->updateItemRow(node); + QmlModelView::rootNodeTypeChanged(type, majorVersion, minorVersion); + if (m_treeModel->isInTree(rootModelNode())) + m_treeModel->updateItemRow(rootModelNode()); } void NavigatorView::auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data) diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.h b/src/plugins/qmldesigner/components/navigator/navigatorview.h index 282ce689ab53d33918f883602de35084edc48520..fa8b3b8530ad4f022b9405d6886472f061e21e1e 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatorview.h +++ b/src/plugins/qmldesigner/components/navigator/navigatorview.h @@ -65,7 +65,7 @@ public: void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList); diff --git a/src/plugins/qmldesigner/core/include/abstractview.h b/src/plugins/qmldesigner/core/include/abstractview.h index 7a087086b1e88b8b34a28afd6064f33275b1e5e7..45c813b181817fd78760ef3d899457c95d02bd8c 100644 --- a/src/plugins/qmldesigner/core/include/abstractview.h +++ b/src/plugins/qmldesigner/core/include/abstractview.h @@ -111,7 +111,7 @@ public: virtual void propertiesRemoved(const QList<AbstractProperty>& propertyList) = 0; virtual void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange) = 0; virtual void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) = 0; - virtual void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) = 0; + virtual void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) = 0; virtual void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList) = 0; @@ -129,6 +129,8 @@ public: QmlModelView *toQmlModelView(); + void changeRootNodeType(const QString &type, int majorVersion, int minorVersion); + protected: void setModel(Model * model); void removeModel(); diff --git a/src/plugins/qmldesigner/core/include/forwardview.h b/src/plugins/qmldesigner/core/include/forwardview.h index dd9a42555f8e03d86850f5a7668c2b257274f9a6..c04ed81eb50b4ac978e63db700d7e9341e54bcb2 100644 --- a/src/plugins/qmldesigner/core/include/forwardview.h +++ b/src/plugins/qmldesigner/core/include/forwardview.h @@ -62,7 +62,7 @@ public: void propertiesRemoved(const QList<AbstractProperty>& propertyList); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); @@ -187,10 +187,10 @@ void ForwardView<ViewType>::bindingPropertiesChanged(const QList<BindingProperty } template <class ViewType> -void ForwardView<ViewType>::nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) +void ForwardView<ViewType>::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { foreach (const ViewTypePointer &view, m_targetViewList) - view->nodeTypeChanged(ModelNode(node, view.data()), type, majorVersion, minorVersion); + view->rootNodeTypeChanged(type, majorVersion, minorVersion); } template <class ViewType> diff --git a/src/plugins/qmldesigner/core/include/modelnode.h b/src/plugins/qmldesigner/core/include/modelnode.h index 59be43c94806f81d06ee281c110eb20e44e80106..64164a7e20343c75e034978f235cfb3dc7841a2c 100644 --- a/src/plugins/qmldesigner/core/include/modelnode.h +++ b/src/plugins/qmldesigner/core/include/modelnode.h @@ -90,7 +90,6 @@ public: ModelNode& operator=(const ModelNode &other); QString type() const; - void changeType(const QString &type, int majorVersion, int minorVersion); QString simplifiedTypeName() const; int minorVersion() const; int majorVersion() const; diff --git a/src/plugins/qmldesigner/core/include/nodeinstanceview.h b/src/plugins/qmldesigner/core/include/nodeinstanceview.h index d1f60fc9a80d791244fbbd25dea6d4f6726642cc..a97d7bf364e304ed1eaab59a64a3f0432c5acfa8 100644 --- a/src/plugins/qmldesigner/core/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/core/include/nodeinstanceview.h @@ -74,7 +74,7 @@ public: void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void fileUrlChanged(const QUrl &oldUrl, const QUrl &newUrl); void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId); diff --git a/src/plugins/qmldesigner/core/include/rewriterview.h b/src/plugins/qmldesigner/core/include/rewriterview.h index 17568e6b70d889e62f613b2796deb44dfbfa6133..fcfad9ad84ff56c562d89af0becd4818d755e3a0 100644 --- a/src/plugins/qmldesigner/core/include/rewriterview.h +++ b/src/plugins/qmldesigner/core/include/rewriterview.h @@ -122,7 +122,7 @@ public: 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 nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); void importAdded(const Import &import); diff --git a/src/plugins/qmldesigner/core/instances/nodeinstance.cpp b/src/plugins/qmldesigner/core/instances/nodeinstance.cpp index b3ebbfe7e95c5cc03d40e68002f430f57f09a827..905e50ce7ae354091c88eb8e42400ff6719068e8 100644 --- a/src/plugins/qmldesigner/core/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/core/instances/nodeinstance.cpp @@ -132,6 +132,8 @@ Internal::ObjectNodeInstance::Pointer NodeInstance::createInstance(const NodeMet { Internal::ObjectNodeInstance::Pointer instance; + qDebug() << __FUNCTION__ << metaInfo.typeName(); + if (metaInfo.isSubclassOf("Qt/QGraphicsView", 4, 6)) instance = Internal::GraphicsViewNodeInstance::create(metaInfo, context, objectToBeWrapped); else if (metaInfo.isSubclassOf("Qt/QmlView", 4, 6)) diff --git a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp index b1de114c96e39f1216be6f7145c10fd8778526a7..c0b36cbce7630db669d93543a375320cf713de91 100644 --- a/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/core/instances/nodeinstanceview.cpp @@ -197,14 +197,13 @@ void NodeInstanceView::removeInstanceAndSubInstances(const ModelNode &node) } } -void NodeInstanceView::nodeTypeChanged(const ModelNode &node, const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) +void NodeInstanceView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) { - removeInstanceAndSubInstances(node); + removeAllInstanceNodeRelationships(); QList<ModelNode> nodeList; - nodeList.append(node.allSubModelNodes()); - nodeList.append(node); + nodeList.append(allModelNodes()); loadNodes(nodeList); } diff --git a/src/plugins/qmldesigner/core/model/abstractview.cpp b/src/plugins/qmldesigner/core/model/abstractview.cpp index ec8c5162e0434afeba141e58f812ac7a769f6302..6721aae8511bd5a4dd4ef631ce862d565f8ed3a8 100644 --- a/src/plugins/qmldesigner/core/model/abstractview.cpp +++ b/src/plugins/qmldesigner/core/model/abstractview.cpp @@ -359,4 +359,11 @@ void AbstractView::emitCustomNotification(const QString &identifier, const QList model()->m_d->notifyCustomNotification(this, identifier, nodeList, data); } +void AbstractView::changeRootNodeType(const QString &type, int majorVersion, int minorVersion) +{ + Internal::WriteLocker locker(m_model.data()); + + m_model.data()->m_d->changeRootNodeType(type, majorVersion, minorVersion); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/core/model/model.cpp b/src/plugins/qmldesigner/core/model/model.cpp index 6368a894a9716c70978d1023960d7ae8fa5d9372..95bd1000ae0d65e75c7819274d16f08dbbdf4933 100644 --- a/src/plugins/qmldesigner/core/model/model.cpp +++ b/src/plugins/qmldesigner/core/model/model.cpp @@ -168,6 +168,7 @@ InternalNode::Pointer ModelPrivate::createNode(const QString &typeString, int minorVersion, const QList<QPair<QString, QVariant> > &propertyList) { + qDebug() << __FUNCTION__ << typeString; if (typeString.isEmpty()) throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, "typeString"); if (!m_metaInfo.nodeMetaInfo(typeString).isValid()) @@ -298,16 +299,15 @@ void ModelPrivate::notifyAuxiliaryDataChanged(const InternalNodePointer &interna } } -void ModelPrivate::notifyNodeTypeChanged(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion) +void ModelPrivate::notifyRootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { bool resetModel = false; QString description; foreach (const QWeakPointer<AbstractView> &view, m_viewList) { Q_ASSERT(view != 0); - ModelNode node(internalNode, model(), view.data()); try { - view->nodeTypeChanged(node, type, majorVersion, minorVersion); + view->rootNodeTypeChanged(type, majorVersion, minorVersion); } catch (RewritingException &e) { description = e.description(); resetModel = true; @@ -834,13 +834,13 @@ void ModelPrivate::clearParent(const InternalNodePointer &node) notifyNodeReparent(node, InternalNodeAbstractProperty::Pointer(), oldParentNode, oldParentPropertyName, AbstractView::NoAdditionalChanges); } -void ModelPrivate::changeType(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion) +void ModelPrivate::changeRootNodeType(const QString &type, int majorVersion, int minorVersion) { - Q_ASSERT(!internalNode.isNull()); - internalNode->setType(type); - internalNode->setMajorVersion(majorVersion); - internalNode->setMinorVersion(minorVersion); - notifyNodeTypeChanged(internalNode, type, majorVersion, minorVersion); + Q_ASSERT(!rootNode().isNull()); + rootNode()->setType(type); + rootNode()->setMajorVersion(majorVersion); + rootNode()->setMinorVersion(minorVersion); + notifyRootNodeTypeChanged(type, majorVersion, minorVersion); } void ModelPrivate::changeNodeOrder(const InternalNode::Pointer &internalParentNode, const QString &listPropertyName, int from, int to) diff --git a/src/plugins/qmldesigner/core/model/model_p.h b/src/plugins/qmldesigner/core/model/model_p.h index f99c49e2953ad62ae492cb301c6a71a5044424ae..82ef75ffe07eb04485cdd56e26208f95d2bca5b3 100644 --- a/src/plugins/qmldesigner/core/model/model_p.h +++ b/src/plugins/qmldesigner/core/model/model_p.h @@ -136,7 +136,7 @@ public: void notifyNodeOrderChanged(const InternalNodeListPropertyPointer &internalListPropertyPointer, const InternalNodePointer &internalNodePointer, int oldIndex); void notifyAuxiliaryDataChanged(const InternalNodePointer &internalNode, const QString &name, const QVariant &data); - void notifyNodeTypeChanged(const InternalNodePointer &internalNode, const QString &type, int majorVersion, int minorVersion); + void notifyRootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void notifyCustomNotification(const AbstractView *senderView, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data); @@ -175,7 +175,7 @@ public: void changeNodeOrder(const InternalNodePointer &internalParentNode, const QString &listPropertyName, int from, int to); void checkPropertyName(const QString &propertyName); void clearParent(const InternalNodePointer &internalNode); - void changeType(const InternalNodePointer & internalNode, const QString &type, int majorVersion, int minorVersion); + void changeRootNodeType(const QString &type, int majorVersion, int minorVersion); InternalNodePointer nodeForId(const QString &id) const; bool hasId(const QString &id) const; diff --git a/src/plugins/qmldesigner/core/model/modelmerger.cpp b/src/plugins/qmldesigner/core/model/modelmerger.cpp index 42c6ebd669566b048d3925e3c0ed52ee5fa8cf59..4707db2eb7c3cd8ae4089e987eaa9a8385e486d5 100644 --- a/src/plugins/qmldesigner/core/model/modelmerger.cpp +++ b/src/plugins/qmldesigner/core/model/modelmerger.cpp @@ -182,7 +182,7 @@ void ModelMerger::replaceModel(const ModelNode &modelNode) syncId(rootNode, modelNode, idRenamingHash); syncNodeProperties(rootNode, modelNode, idRenamingHash, view()); syncNodeListProperties(rootNode, modelNode, idRenamingHash, view()); - rootNode.changeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion()); + m_view->changeRootNodeType(modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion()); } } //namespace QmlDesigner diff --git a/src/plugins/qmldesigner/core/model/modelnode.cpp b/src/plugins/qmldesigner/core/model/modelnode.cpp index 0026a6566d440773cc23dab783d6e1888013d428..f3f151c5b76999c695cb1997dca380834362e089 100644 --- a/src/plugins/qmldesigner/core/model/modelnode.cpp +++ b/src/plugins/qmldesigner/core/model/modelnode.cpp @@ -203,19 +203,6 @@ QString ModelNode::type() const return m_internalNode->type(); } -/*! \brief set the fully-qualified type name of the node -*/ -void ModelNode::changeType(const QString &type, int majorVersion, int minorVersion) -{ - Internal::WriteLocker locker(m_model.data()); - if (!isValid()) { - Q_ASSERT_X(isValid(), Q_FUNC_INFO, "model node is invalid"); - throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__); - } - - m_model.data()->m_d->changeType(internalNode(), type, majorVersion, minorVersion); -} - /*! \brief minor number of the Qml Type \return minor number */ diff --git a/src/plugins/qmldesigner/core/model/rewriterview.cpp b/src/plugins/qmldesigner/core/model/rewriterview.cpp index 698486fe900444f114176b495875c91b12a0658f..05e1c660f4a1e02d4c8cfde39e7d671a98054fbb 100644 --- a/src/plugins/qmldesigner/core/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/core/model/rewriterview.cpp @@ -319,13 +319,13 @@ void RewriterView::nodeOrderChanged(const NodeListProperty &listProperty, const applyChanges(); } -void RewriterView::nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) +void RewriterView::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { Q_ASSERT(textModifier()); if (textToModelMerger()->isActive()) return; - modelToTextMerger()->nodeTypeChanged(node, type, majorVersion, minorVersion); + modelToTextMerger()->nodeTypeChanged(rootModelNode(), type, majorVersion, minorVersion); if (!isModificationGroupActive()) applyChanges(); diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp index bf089454ecdfe0c31323c7600906022a297d2de7..c6b2c1bab599073a38f7a8b456550eb05b96df19 100644 --- a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp @@ -543,7 +543,7 @@ ModelNode ModelAmender::listPropertyMissingModelNode(NodeListProperty &modelProp void ModelAmender::typeDiffers(bool isRootNode, ModelNode &modelNode, const QmlDomObject &domObject) { if (isRootNode) { - modelNode.changeType(domObject.objectType(), domObject.objectTypeMajorVersion(), domObject.objectTypeMinorVersion()); + modelNode.view()->changeRootNodeType(domObject.objectType(), domObject.objectTypeMajorVersion(), domObject.objectTypeMinorVersion()); } else { NodeAbstractProperty parentProperty = modelNode.parentProperty(); int nodeIndex = -1; diff --git a/src/plugins/qmldesigner/core/model/viewlogger.cpp b/src/plugins/qmldesigner/core/model/viewlogger.cpp index 64c4eef185e149833254fc2819d01b2bc0b019f6..fe193e239c49c76a10cef2da6e6379e041ebd621 100644 --- a/src/plugins/qmldesigner/core/model/viewlogger.cpp +++ b/src/plugins/qmldesigner/core/model/viewlogger.cpp @@ -151,9 +151,9 @@ void ViewLogger::bindingPropertiesChanged(const QList<BindingProperty>& property m_output << time() << indent() << property << endl; } -void ViewLogger::nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion) +void ViewLogger::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { - m_output << time() << indent("nodeTypeChanged:") << node << type << majorVersion << minorVersion << endl; + m_output << time() << indent("rootNodeTypeChanged:") << rootModelNode() << type << majorVersion << minorVersion << endl; } void ViewLogger::selectedNodesChanged(const QList<ModelNode> &selectedNodeList, diff --git a/src/plugins/qmldesigner/core/model/viewlogger.h b/src/plugins/qmldesigner/core/model/viewlogger.h index 37c6e2aef90a4313d031672e816718139da1a7c4..dddf325d851be347dce559a6200b19f096c8fc13 100644 --- a/src/plugins/qmldesigner/core/model/viewlogger.h +++ b/src/plugins/qmldesigner/core/model/viewlogger.h @@ -56,7 +56,7 @@ public: void propertiesRemoved(const QList<AbstractProperty>& propertyList); void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange); void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange); - void nodeTypeChanged(const ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void selectedNodesChanged(const QList<ModelNode> &selectedNodeList, const QList<ModelNode> &lastSelectedNodeList); diff --git a/tests/auto/qml/qmldesigner/testview.cpp b/tests/auto/qml/qmldesigner/testview.cpp index 4f990fc569e5aaeab5661f4a19d7dde839997439..9789f35873a151fb82428b3845c2b4a33cfdaec9 100644 --- a/tests/auto/qml/qmldesigner/testview.cpp +++ b/tests/auto/qml/qmldesigner/testview.cpp @@ -60,10 +60,10 @@ void TestView::nodeIdChanged(const QmlDesigner::ModelNode &node, const QString& m_methodCalls += MethodCall("nodeIdChanged", QStringList() << node.id() << newId << oldId); } -void TestView::nodeTypeChanged(const QmlDesigner::ModelNode &node,const QString &type, int majorVersion, int minorVersion) +void TestView::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) { - QmlDesigner::QmlModelView::nodeTypeChanged(node, type, majorVersion, minorVersion); - m_methodCalls += MethodCall("nodeTypeChanged", QStringList() << node.id() << type << QString::number(majorVersion) << QString::number(minorVersion)); + QmlDesigner::QmlModelView::rootNodeTypeChanged(type, majorVersion, minorVersion); + m_methodCalls += MethodCall("rootNodeTypeChanged", QStringList() << rootModelNode().id() << type << QString::number(majorVersion) << QString::number(minorVersion)); } void TestView::fileUrlChanged(const QUrl & oldBaseUrl, const QUrl &newBaseUrl) diff --git a/tests/auto/qml/qmldesigner/testview.h b/tests/auto/qml/qmldesigner/testview.h index 729d2dc99072cda222fff4b878e69567f41db1fb..a1cd651d885db70b79b5fa2043a4c7d6a2016741 100644 --- a/tests/auto/qml/qmldesigner/testview.h +++ b/tests/auto/qml/qmldesigner/testview.h @@ -58,7 +58,7 @@ public: void nodeRemoved(const QmlDesigner::ModelNode &removedNode, const QmlDesigner::NodeAbstractProperty &parentProperty, AbstractView::PropertyChangeFlags propertyChange); void nodeReparented(const QmlDesigner::ModelNode &node, const QmlDesigner::NodeAbstractProperty &newPropertyParent, const QmlDesigner::NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange); void nodeIdChanged(const QmlDesigner::ModelNode& node, const QString& newId, const QString& oldId); - void nodeTypeChanged(const QmlDesigner::ModelNode &node,const QString &type, int majorVersion, int minorVersion); + void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion); void bindingPropertiesChanged(const QList<QmlDesigner::BindingProperty>& propertyList, PropertyChangeFlags propertyChange); void variantPropertiesChanged(const QList<QmlDesigner::VariantProperty>& propertyList, PropertyChangeFlags propertyChange);