QmlDesigner: implenting expression() in QmlObjectNode

This function returns the expression in a certain state
This commit is contained in:
Thomas Hartmann
2010-04-21 14:47:54 +02:00
parent 8999b35fcf
commit a85fae4ba3
2 changed files with 20 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ public:
bool hasBindingProperty(const QString &name) const; bool hasBindingProperty(const QString &name) const;
bool propertyAffectedByCurrentState(const QString &name) const; bool propertyAffectedByCurrentState(const QString &name) const;
QVariant modelValue(const QString &name) const; QVariant modelValue(const QString &name) const;
QString expression(const QString &name) const;
bool isInBaseState() const; bool isInBaseState() const;
QmlPropertyChanges propertyChangeForCurrentState() const; QmlPropertyChanges propertyChangeForCurrentState() const;

View File

@@ -175,6 +175,25 @@ QVariant QmlObjectNode::modelValue(const QString &name) const
return propertyChanges.modelNode().variantProperty(name).value(); return propertyChanges.modelNode().variantProperty(name).value();
} }
QString QmlObjectNode::expression(const QString &name) const
{
if (!isValid())
throw new InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (currentState().isBaseState())
return modelNode().bindingProperty(name).expression();
if (!currentState().hasPropertyChanges(modelNode()))
return modelNode().bindingProperty(name).expression();
QmlPropertyChanges propertyChanges(currentState().propertyChanges(modelNode()));
if (!propertyChanges.modelNode().hasProperty(name))
return modelNode().bindingProperty(name).expression();
return propertyChanges.modelNode().bindingProperty(name).expression();
}
/*! \brief returns if ObjectNode is the BaseState /*! \brief returns if ObjectNode is the BaseState
\return true if the ObjectNode is in the BaseState \return true if the ObjectNode is in the BaseState