From a85fae4ba3e49978d99f88cb6df3fa7510f56d8d Mon Sep 17 00:00:00 2001
From: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Date: Wed, 21 Apr 2010 14:47:54 +0200
Subject: [PATCH] QmlDesigner: implenting  expression() in QmlObjectNode

This function returns the expression in a certain state
---
 .../qmldesigner/core/include/qmlobjectnode.h  |  1 +
 .../qmldesigner/core/model/qmlobjectnode.cpp  | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/plugins/qmldesigner/core/include/qmlobjectnode.h b/src/plugins/qmldesigner/core/include/qmlobjectnode.h
index 0e321f84856..5dd0ca64488 100644
--- a/src/plugins/qmldesigner/core/include/qmlobjectnode.h
+++ b/src/plugins/qmldesigner/core/include/qmlobjectnode.h
@@ -68,6 +68,7 @@ public:
     bool hasBindingProperty(const QString &name) const;
     bool propertyAffectedByCurrentState(const QString &name) const;
     QVariant modelValue(const QString &name) const;
+    QString expression(const QString &name) const;
     bool isInBaseState() const;
     QmlPropertyChanges propertyChangeForCurrentState() const;
 
diff --git a/src/plugins/qmldesigner/core/model/qmlobjectnode.cpp b/src/plugins/qmldesigner/core/model/qmlobjectnode.cpp
index 3048cb7b904..ef88ccfe01c 100644
--- a/src/plugins/qmldesigner/core/model/qmlobjectnode.cpp
+++ b/src/plugins/qmldesigner/core/model/qmlobjectnode.cpp
@@ -175,6 +175,25 @@ QVariant QmlObjectNode::modelValue(const QString &name) const
     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
 
 \return true if the ObjectNode is in the BaseState
-- 
GitLab