From b28e48c10b6178b83be1df00883c9a4f4e11e609 Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Fri, 6 Oct 2017 19:02:44 -0700 Subject: [PATCH] Added read-only 'expression' property to QunatitySpinBox and renamed 'boundTo' to 'binding'. --- src/Gui/QuantitySpinBox.cpp | 14 ++++++++++++-- src/Gui/QuantitySpinBox.h | 6 +++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index ce9a81eea8..ce511cde40 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -328,8 +328,18 @@ void QuantitySpinBox::setBoundToByName(const QString &qstr) } } -void Gui::QuantitySpinBox::onChange() { - +QString Gui::QuantitySpinBox::expressionText() const +{ + Q_D(const QuantitySpinBox); + if (isBound()) { + return QString::fromStdString(getExpressionString()); + } + return QString(); +} + + +void Gui::QuantitySpinBox::onChange() +{ Q_ASSERT(isBound()); if (getExpression()) { diff --git a/src/Gui/QuantitySpinBox.h b/src/Gui/QuantitySpinBox.h index 4041d29492..d754d091b6 100644 --- a/src/Gui/QuantitySpinBox.h +++ b/src/Gui/QuantitySpinBox.h @@ -45,7 +45,8 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep) Q_PROPERTY(double rawValue READ rawValue WRITE setValue NOTIFY valueChanged) Q_PROPERTY(Base::Quantity value READ value WRITE setValue NOTIFY valueChanged USER true) - Q_PROPERTY(QString boundTo READ boundToName WRITE setBoundToByName) + Q_PROPERTY(QString binding READ boundToName WRITE setBoundToByName) + Q_PROPERTY(QString expression READ expressionText) public: using ExpressionBinding::apply; @@ -95,6 +96,9 @@ public: /// Sets the path of the bound property void setBoundToByName(const QString &path); + /// Gets the expression as a string + QString expressionText() const; + /// Set the number portion selected void selectNumber();