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: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
Thomas Hartmann
2013-08-05 12:10:12 +02:00
parent 361821c8ec
commit 37cc7657e2
2 changed files with 24 additions and 0 deletions

View File

@@ -184,6 +184,8 @@ public:
NodeSourceType nodeSourceType() const;
bool isComponent() const;
private: // functions
Internal::InternalNodePointer internalNode() const;

View File

@@ -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;
}
}