Commit 37cc7657 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.Model: adding isComponent to ModelNode

This function checks if the ModelNode is a Component or has a delegate
which is a Component.

Change-Id: I6bc92c3246b58eb04a5d37722e821dbed52147e5
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 361821c8
......@@ -184,6 +184,8 @@ public:
NodeSourceType nodeSourceType() const;
bool isComponent() const;
private: // functions
Internal::InternalNodePointer internalNode() const;
......
......@@ -984,4 +984,26 @@ ModelNode::NodeSourceType ModelNode::nodeSourceType() const
}
bool ModelNode::isComponent() const
{
if (!isValid())
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (metaInfo().isFileComponent())
return true;
if (nodeSourceType() == ModelNode::NodeWithComponentSource)
return true;
if (metaInfo().isView() && hasNodeProperty("delegate")) {
if (nodeProperty("delegate").modelNode().metaInfo().isFileComponent())
return true;
if (nodeProperty("delegate").modelNode().nodeSourceType() == ModelNode::NodeWithComponentSource)
return true;
}
return false;
}
}
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