QuantitySpinBox: Make sure Python code is emitted also when expressions are not used.

In that case, the property should be set directly.
This commit is contained in:
Eivind Kvedalen 2015-11-10 01:09:27 +01:00 committed by wmayer
parent 61a3997ef2
commit 081bc6b107
4 changed files with 9 additions and 11 deletions

View File

@ -64,6 +64,7 @@ void Gui::ExpressionBinding::setExpression(boost::shared_ptr<Expression> expr)
}
lastExpression = getExpression();
docObj->ExpressionEngine.setValue(path, expr);
}
@ -146,11 +147,11 @@ bool ExpressionBinding::apply(const std::string & propName)
if (!docObj)
throw Base::Exception("Document object not found.");
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', None)",
docObj->getDocument()->getName(),
docObj->getNameInDocument(),
path.toEscapedString().c_str());
return true;
if (lastExpression)
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', None)",
docObj->getDocument()->getName(),
docObj->getNameInDocument(),
path.toEscapedString().c_str());
}
return false;

View File

@ -58,6 +58,7 @@ protected:
private:
App::ObjectIdentifier path;
boost::shared_ptr<App::Expression> lastExpression;
protected:
QLabel* iconLabel;
QPalette defaultPalette;

View File

@ -321,11 +321,6 @@ bool QuantitySpinBox::apply(const std::string & propName)
return false;
}
bool QuantitySpinBox::apply()
{
return ExpressionBinding::apply();
}
void QuantitySpinBox::resizeEvent(QResizeEvent * event)
{
QAbstractSpinBox::resizeEvent(event);

View File

@ -46,6 +46,8 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind
Q_PROPERTY(Base::Quantity value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
using ExpressionBinding::apply;
explicit QuantitySpinBox(QWidget *parent = 0);
virtual ~QuantitySpinBox();
@ -101,7 +103,6 @@ public:
void setExpression(boost::shared_ptr<App::Expression> expr);
void bind(const App::ObjectIdentifier &_path);
bool apply(const std::string &propName);
bool apply();
public Q_SLOTS:
/// Sets the field with a quantity