Commit cc75d77c authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Add static valid functions for the qml objects



Change-Id: Ied3ec55580471893c8899946455ce2b5198c6f17
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 56de1574
......@@ -51,6 +51,7 @@ public:
QmlItemNode() : QmlObjectNode() {}
QmlItemNode(const ModelNode &modelNode) : QmlObjectNode(modelNode) {}
bool isValid() const;
static bool isValidQmlItemNode(const ModelNode &modelNode);
bool isRootNode() const;
static bool isItemOrWindow(const ModelNode &modelNode);
......
......@@ -43,6 +43,7 @@ public:
operator ModelNode() const;
ModelNode modelNode();
const ModelNode modelNode() const;
static bool isValidQmlModelNodeFacade(const ModelNode &modelNode);
virtual bool isValid() const;
virtual ~QmlModelNodeFacade();
QmlModelNodeFacade();
......@@ -50,6 +51,7 @@ public:
bool isRootNode() const;
QmlModelView* qmlModelView() const;
protected:
QmlModelNodeFacade(const ModelNode &modelNode);
......
......@@ -48,6 +48,9 @@ public:
QmlObjectNode();
QmlObjectNode(const ModelNode &modelNode);
static bool isValidQmlObjectNode(const ModelNode &modelNode);
bool isValid() const;
bool hasNodeParent() const;
bool hasInstanceParent() const;
bool hasInstanceParentItem() const;
......
......@@ -50,7 +50,12 @@ bool QmlItemNode::isItemOrWindow(const ModelNode &modelNode)
bool QmlItemNode::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && isItemOrWindow(modelNode());
return isValidQmlItemNode(modelNode());
}
bool QmlItemNode::isValidQmlItemNode(const ModelNode &modelNode)
{
return isValidQmlObjectNode(modelNode) && modelNode.metaInfo().isValid() && isItemOrWindow(modelNode);
}
bool QmlItemNode::isRootNode() const
......
......@@ -59,7 +59,7 @@ const ModelNode QmlModelNodeFacade::modelNode() const
bool QmlModelNodeFacade::isValid() const
{
return modelNode().isValid() && qmlModelView() && qmlModelView()->nodeInstanceView() && qmlModelView()->hasInstanceForModelNode(modelNode()) && qmlModelView()->instanceForModelNode(modelNode()).isValid();
return isValidQmlModelNodeFacade(m_modelNode);
}
QmlModelView* QmlModelNodeFacade::qmlModelView() const
......@@ -67,6 +67,13 @@ QmlModelView* QmlModelNodeFacade::qmlModelView() const
return modelNode().view()->toQmlModelView();
}
bool QmlModelNodeFacade::isValidQmlModelNodeFacade(const ModelNode &modelNode)
{
QmlModelView * qmlModelView = modelNode.view()->toQmlModelView();
return modelNode.isValid() && qmlModelView && qmlModelView->nodeInstanceView() && qmlModelView->hasInstanceForModelNode(modelNode) && qmlModelView->instanceForModelNode(modelNode).isValid();
}
bool QmlModelNodeFacade::isRootNode() const
{
return modelNode().isRootNode();
......
......@@ -458,6 +458,17 @@ QmlObjectNode::QmlObjectNode(const ModelNode &modelNode)
: QmlModelNodeFacade(modelNode)
{
}
bool QmlObjectNode::isValidQmlObjectNode(const ModelNode &modelNode)
{
return isValidQmlModelNodeFacade(modelNode);
}
bool QmlObjectNode::isValid() const
{
return isValidQmlObjectNode(modelNode());
}
bool QmlObjectNode::hasNodeParent() const
{
return modelNode().hasParentProperty();
......
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