Commit ab3442ea authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.model extending QmlState

parent 7226937c
......@@ -89,6 +89,8 @@ public:
bool isAncestorOf(const QmlObjectNode &objectNode) const;
static QVariant instanceValue(const ModelNode &modelNode, const QString &name);
protected:
NodeInstance nodeInstance() const;
QmlObjectNode nodeForInstance(const NodeInstance &instance) const;
......
......@@ -38,6 +38,7 @@ namespace QmlDesigner {
class QmlModelView;
class QmlModelStateGroup;
class QmlObjectNode;
class CORESHARED_EXPORT QmlModelState : public QmlModelNodeFacade
{
......@@ -59,6 +60,7 @@ public:
void removePropertyChanges(const ModelNode &node);
bool affectsModelNode(const ModelNode &node) const;
QList<QmlObjectNode> allAffectedNodes() const;
QString name() const;
void setName(const QString &name);
bool isValid() const;
......
......@@ -93,9 +93,8 @@ instanciated instance of this object.
*/
QVariant QmlObjectNode::instanceValue(const QString &name) const
{
Q_ASSERT(qmlModelView()->hasInstanceForModelNode(modelNode()));
return qmlModelView()->instanceForModelNode(modelNode()).property(name);
{
return instanceValue(modelNode(), name);
}
......@@ -378,6 +377,15 @@ bool QmlObjectNode::isAncestorOf(const QmlObjectNode &objectNode) const
return modelNode().isAncestorOf(objectNode.modelNode());
}
QVariant QmlObjectNode::instanceValue(const ModelNode &modelNode, const QString &name)
{
QmlModelView *modelView = qobject_cast<QmlModelView*>(modelNode.view());
if (!modelView)
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
Q_ASSERT(modelView->hasInstanceForModelNode(modelNode));
return modelView->instanceForModelNode(modelNode).property(name);
}
NodeInstance QmlObjectNode::nodeInstance() const
{
return qmlModelView()->nodeInstanceView()->instanceForNode(modelNode());
......
......@@ -189,6 +189,9 @@ void QmlModelState::removePropertyChanges(const ModelNode &node)
{
//### exception if not valid
if (!isValid())
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (isBaseState())
return;
......@@ -211,6 +214,19 @@ bool QmlModelState::affectsModelNode(const ModelNode &node) const
return !stateOperations(node).isEmpty();
}
QList<QmlObjectNode> QmlModelState::allAffectedNodes() const
{
QList<QmlObjectNode> returnList;
foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
//### exception if not valid QmlModelStateOperation
if (QmlModelStateOperation(childNode).isValid() &&
!returnList.contains(QmlModelStateOperation(childNode).target()))
returnList.append(QmlModelStateOperation(childNode).target());
}
return returnList;
}
QString QmlModelState::name() const
{
if (isBaseState())
......
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