QmlDesigner: Rename instanceForNode in instanceForModelNode

Change-Id: I182d5b557f5770816059897e746709d054ecac51
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Marco Bubke
2013-07-29 17:20:47 +02:00
parent b756be03ae
commit 237d173160
4 changed files with 27 additions and 27 deletions

View File

@@ -122,7 +122,7 @@ public:
void actualStateChanged(const ModelNode &node); void actualStateChanged(const ModelNode &node);
QList<NodeInstance> instances() const; QList<NodeInstance> instances() const;
NodeInstance instanceForNode(const ModelNode &node) const ; NodeInstance instanceForModelNode(const ModelNode &node) const ;
bool hasInstanceForNode(const ModelNode &node) const; bool hasInstanceForNode(const ModelNode &node) const;
NodeInstance instanceForId(qint32 id); NodeInstance instanceForId(qint32 id);

View File

@@ -161,7 +161,7 @@ void NodeInstanceView::modelAttached(Model *model)
ModelNode stateNode = actualStateNode(); ModelNode stateNode = actualStateNode();
if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) { if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) {
NodeInstance newStateInstance = instanceForNode(stateNode); NodeInstance newStateInstance = instanceForModelNode(stateNode);
activateState(newStateInstance); activateState(newStateInstance);
} }
@@ -205,7 +205,7 @@ void NodeInstanceView::restartProcess()
ModelNode stateNode = actualStateNode(); ModelNode stateNode = actualStateNode();
if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) { if (stateNode.isValid() && stateNode.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) {
NodeInstance newStateInstance = instanceForNode(stateNode); NodeInstance newStateInstance = instanceForModelNode(stateNode);
activateState(newStateInstance); activateState(newStateInstance);
} }
} }
@@ -404,7 +404,7 @@ void NodeInstanceView::fileUrlChanged(const QUrl &/*oldUrl*/, const QUrl &newUrl
void NodeInstanceView::nodeIdChanged(const ModelNode& node, const QString& /*newId*/, const QString& /*oldId*/) void NodeInstanceView::nodeIdChanged(const ModelNode& node, const QString& /*newId*/, const QString& /*oldId*/)
{ {
if (hasInstanceForNode(node)) { if (hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
nodeInstanceServer()->changeIds(createChangeIdsCommand(QList<NodeInstance>() << instance)); nodeInstanceServer()->changeIds(createChangeIdsCommand(QList<NodeInstance>() << instance));
} }
} }
@@ -417,12 +417,12 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty & listProperty,
qint32 containerInstanceId = -1; qint32 containerInstanceId = -1;
ModelNode containerNode = listProperty.parentModelNode(); ModelNode containerNode = listProperty.parentModelNode();
if (hasInstanceForNode(containerNode)) if (hasInstanceForNode(containerNode))
containerInstanceId = instanceForNode(containerNode).instanceId(); containerInstanceId = instanceForModelNode(containerNode).instanceId();
foreach (const ModelNode &node, listProperty.toModelNodeList()) { foreach (const ModelNode &node, listProperty.toModelNodeList()) {
qint32 instanceId = -1; qint32 instanceId = -1;
if (hasInstanceForNode(node)) { if (hasInstanceForNode(node)) {
instanceId = instanceForNode(node).instanceId(); instanceId = instanceForModelNode(node).instanceId();
ReparentContainer container(instanceId, containerInstanceId, propertyName, containerInstanceId, propertyName); ReparentContainer container(instanceId, containerInstanceId, propertyName, containerInstanceId, propertyName);
containerList.append(container); containerList.append(container);
} }
@@ -493,7 +493,7 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const Propert
{ {
if ((node.isRootNode() && (name == "width" || name == "height")) || name.endsWith(PropertyName("@NodeInstance"))) { if ((node.isRootNode() && (name == "width" || name == "height")) || name.endsWith(PropertyName("@NodeInstance"))) {
if (hasInstanceForNode(node)) { if (hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
QVariant value = data; QVariant value = data;
if (value.isValid()) { if (value.isValid()) {
PropertyValueContainer container(instance.instanceId(), name, value, TypeName()); PropertyValueContainer container(instance.instanceId(), name, value, TypeName());
@@ -523,7 +523,7 @@ void NodeInstanceView::customNotification(const AbstractView *view, const QStrin
void NodeInstanceView::nodeSourceChanged(const ModelNode &node, const QString & newNodeSource) void NodeInstanceView::nodeSourceChanged(const ModelNode &node, const QString & newNodeSource)
{ {
if (hasInstanceForNode(node)) { if (hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
ChangeNodeSourceCommand changeNodeSourceCommand(instance.instanceId(), newNodeSource); ChangeNodeSourceCommand changeNodeSourceCommand(instance.instanceId(), newNodeSource);
nodeInstanceServer()->changeNodeSource(changeNodeSourceCommand); nodeInstanceServer()->changeNodeSource(changeNodeSourceCommand);
} }
@@ -541,7 +541,7 @@ void NodeInstanceView::rewriterEndTransaction()
void NodeInstanceView::actualStateChanged(const ModelNode &node) void NodeInstanceView::actualStateChanged(const ModelNode &node)
{ {
NodeInstance newStateInstance = instanceForNode(node); NodeInstance newStateInstance = instanceForModelNode(node);
if (newStateInstance.isValid() && node.metaInfo().isSubclassOf("QtQuick.State", 1, 0)) if (newStateInstance.isValid() && node.metaInfo().isSubclassOf("QtQuick.State", 1, 0))
nodeInstanceView()->activateState(newStateInstance); nodeInstanceView()->activateState(newStateInstance);
@@ -576,7 +576,7 @@ QList<NodeInstance> NodeInstanceView::instances() const
\returns NodeStance for ModelNode. \returns NodeStance for ModelNode.
\see NodeInstance \see NodeInstance
*/ */
NodeInstance NodeInstanceView::instanceForNode(const ModelNode &node) const NodeInstance NodeInstanceView::instanceForModelNode(const ModelNode &node) const
{ {
Q_ASSERT(node.isValid()); Q_ASSERT(node.isValid());
Q_ASSERT(m_nodeInstanceHash.contains(node)); Q_ASSERT(m_nodeInstanceHash.contains(node));
@@ -657,7 +657,7 @@ void NodeInstanceView::insertInstanceRelationships(const NodeInstance &instance)
void NodeInstanceView::removeInstanceNodeRelationship(const ModelNode &node) void NodeInstanceView::removeInstanceNodeRelationship(const ModelNode &node)
{ {
Q_ASSERT(m_nodeInstanceHash.contains(node)); Q_ASSERT(m_nodeInstanceHash.contains(node));
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
m_nodeInstanceHash.remove(node); m_nodeInstanceHash.remove(node);
instance.makeInvalid(); instance.makeInvalid();
} }
@@ -759,7 +759,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
variantPropertyList.append(node.variantProperties()); variantPropertyList.append(node.variantProperties());
bindingPropertyList.append(node.bindingProperties()); bindingPropertyList.append(node.bindingProperties());
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
QHashIterator<PropertyName, QVariant> auxiliaryIterator(node.auxiliaryData()); QHashIterator<PropertyName, QVariant> auxiliaryIterator(node.auxiliaryData());
while (auxiliaryIterator.hasNext()) { while (auxiliaryIterator.hasNext()) {
auxiliaryIterator.next(); auxiliaryIterator.next();
@@ -795,7 +795,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
foreach (const NodeInstance &instance, instanceList) { foreach (const NodeInstance &instance, instanceList) {
if (instance.modelNode().hasParentProperty()) { if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty(); NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name()); ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name());
reparentContainerList.append(container); reparentContainerList.append(container);
} }
} }
@@ -813,7 +813,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
foreach (const VariantProperty &property, variantPropertyList) { foreach (const VariantProperty &property, variantPropertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyValueContainer container(instance.instanceId(), property.name(), property.value(), property.dynamicTypeName()); PropertyValueContainer container(instance.instanceId(), property.name(), property.value(), property.dynamicTypeName());
valueContainerList.append(container); valueContainerList.append(container);
} }
@@ -823,7 +823,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
foreach (const BindingProperty &property, bindingPropertyList) { foreach (const BindingProperty &property, bindingPropertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyBindingContainer container(instance.instanceId(), property.name(), property.expression(), property.dynamicTypeName()); PropertyBindingContainer container(instance.instanceId(), property.name(), property.expression(), property.dynamicTypeName());
bindingContainerList.append(container); bindingContainerList.append(container);
} }
@@ -894,7 +894,7 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
foreach (const NodeInstance &instance, instanceList) { foreach (const NodeInstance &instance, instanceList) {
if (instance.modelNode().hasParentProperty()) { if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty(); NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name()); ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name());
containerList.append(container); containerList.append(container);
} }
} }
@@ -910,14 +910,14 @@ ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const
qint32 oldParentInstanceId = -1; qint32 oldParentInstanceId = -1;
if (newPropertyParent.isValid() && hasInstanceForNode(newPropertyParent.parentModelNode())) if (newPropertyParent.isValid() && hasInstanceForNode(newPropertyParent.parentModelNode()))
newParentInstanceId = instanceForNode(newPropertyParent.parentModelNode()).instanceId(); newParentInstanceId = instanceForModelNode(newPropertyParent.parentModelNode()).instanceId();
if (oldPropertyParent.isValid() && hasInstanceForNode(oldPropertyParent.parentModelNode())) if (oldPropertyParent.isValid() && hasInstanceForNode(oldPropertyParent.parentModelNode()))
oldParentInstanceId = instanceForNode(oldPropertyParent.parentModelNode()).instanceId(); oldParentInstanceId = instanceForModelNode(oldPropertyParent.parentModelNode()).instanceId();
ReparentContainer container(instanceForNode(node).instanceId(), oldParentInstanceId, oldPropertyParent.name(), newParentInstanceId, newPropertyParent.name()); ReparentContainer container(instanceForModelNode(node).instanceId(), oldParentInstanceId, oldPropertyParent.name(), newParentInstanceId, newPropertyParent.name());
containerList.append(container); containerList.append(container);
@@ -936,7 +936,7 @@ ChangeValuesCommand NodeInstanceView::createChangeValueCommand(const QList<Varia
foreach (const VariantProperty &property, propertyList) { foreach (const VariantProperty &property, propertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyValueContainer container(instance.instanceId(), property.name(), property.value(), property.dynamicTypeName()); PropertyValueContainer container(instance.instanceId(), property.name(), property.value(), property.dynamicTypeName());
containerList.append(container); containerList.append(container);
} }
@@ -953,7 +953,7 @@ ChangeBindingsCommand NodeInstanceView::createChangeBindingCommand(const QList<B
foreach (const BindingProperty &property, propertyList) { foreach (const BindingProperty &property, propertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyBindingContainer container(instance.instanceId(), property.name(), property.expression(), property.dynamicTypeName()); PropertyBindingContainer container(instance.instanceId(), property.name(), property.expression(), property.dynamicTypeName());
containerList.append(container); containerList.append(container);
} }
@@ -984,7 +984,7 @@ RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const QLis
QVector<qint32> idList; QVector<qint32> idList;
foreach (const ModelNode &node, nodeList) { foreach (const ModelNode &node, nodeList) {
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
if (instance.instanceId() >= 0) if (instance.instanceId() >= 0)
idList.append(instance.instanceId()); idList.append(instance.instanceId());
@@ -999,7 +999,7 @@ RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const Mode
QVector<qint32> idList; QVector<qint32> idList;
if (node.isValid() && hasInstanceForNode(node)) if (node.isValid() && hasInstanceForNode(node))
idList.append(instanceForNode(node).instanceId()); idList.append(instanceForModelNode(node).instanceId());
return RemoveInstancesCommand(idList); return RemoveInstancesCommand(idList);
} }
@@ -1011,7 +1011,7 @@ RemovePropertiesCommand NodeInstanceView::createRemovePropertiesCommand(const QL
foreach (const AbstractProperty &property, propertyList) { foreach (const AbstractProperty &property, propertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForNode(node)) { if (node.isValid() && hasInstanceForNode(node)) {
NodeInstance instance = instanceForNode(node); NodeInstance instance = instanceForModelNode(node);
PropertyAbstractContainer container(instance.instanceId(), property.name(), property.dynamicTypeName()); PropertyAbstractContainer container(instance.instanceId(), property.name(), property.dynamicTypeName());
containerList.append(container); containerList.append(container);
} }

View File

@@ -74,7 +74,7 @@ bool QmlModelNodeFacade::isValidQmlModelNodeFacade(const ModelNode &modelNode)
&& qmlModelView() && qmlModelView()
&& qmlModelView()->nodeInstanceView() && qmlModelView()->nodeInstanceView()
&& qmlModelView()->nodeInstanceView()->hasInstanceForNode(modelNode) && qmlModelView()->nodeInstanceView()->hasInstanceForNode(modelNode)
&& qmlModelView()->nodeInstanceView()->instanceForNode(modelNode).isValid(); && qmlModelView()->nodeInstanceView()->instanceForModelNode(modelNode).isValid();
} }
bool QmlModelNodeFacade::isRootNode() const bool QmlModelNodeFacade::isRootNode() const

View File

@@ -404,7 +404,7 @@ bool QmlObjectNode::isAncestorOf(const QmlObjectNode &objectNode) const
QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, const PropertyName &name) QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, const PropertyName &name)
{ {
Q_ASSERT(modelNode.view()->nodeInstanceView()->hasInstanceForNode(modelNode)); Q_ASSERT(modelNode.view()->nodeInstanceView()->hasInstanceForNode(modelNode));
return modelNode.view()->nodeInstanceView()->instanceForNode(modelNode).property(name); return modelNode.view()->nodeInstanceView()->instanceForModelNode(modelNode).property(name);
} }
QString QmlObjectNode::generateTranslatableText(const QString &text) QString QmlObjectNode::generateTranslatableText(const QString &text)
@@ -428,7 +428,7 @@ bool QmlObjectNode::instanceHasBinding(const PropertyName &name) const
NodeInstance QmlObjectNode::nodeInstance() const NodeInstance QmlObjectNode::nodeInstance() const
{ {
return qmlModelView()->nodeInstanceView()->instanceForNode(modelNode()); return qmlModelView()->nodeInstanceView()->instanceForModelNode(modelNode());
} }
QmlObjectNode QmlObjectNode::nodeForInstance(const NodeInstance &instance) const QmlObjectNode QmlObjectNode::nodeForInstance(const NodeInstance &instance) const