Commit f6a06085 authored by Marco Bubke's avatar Marco Bubke

Change changeNodeType in changeRootNodeType

parent 3f8988b5
......@@ -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);
......
......@@ -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);
......
......@@ -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*/) {}
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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*/) {};
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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();
......
......@@ -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>
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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))
......
......@@ -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);
}
......
......@@ -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
......@@ -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)
......
......@@ -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;
......
......@@ -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
......
......@@ -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
*/
......
......@@ -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();
......
......@@ -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;
......
......@@ -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,
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment