forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user