diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 9871334e74..bd06c653b7 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -464,7 +464,7 @@ QVariant PropertyItem::data(int column, int role) const bool PropertyItem::setData (const QVariant& value) { cleared = false; - + // This is the basic mechanism to set the value to // a property and if no property is set for this item // it delegates it to its parent which sets then the @@ -499,12 +499,14 @@ int PropertyItem::row() const return 0; } -void PropertyItem::bind(const App::ObjectIdentifier& _path) { +void PropertyItem::bind(const App::ObjectIdentifier& _path) +{ Gui::ExpressionBinding::bind(_path); propertyBound(); } -void PropertyItem::bind(const App::Property& prop) { +void PropertyItem::bind(const App::Property& prop) +{ Gui::ExpressionBinding::bind(prop); propertyBound(); } @@ -652,7 +654,7 @@ QVariant PropertyIntegerItem::value(const App::Property* prop) const void PropertyIntegerItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code - if(!hasExpression()) { + if (!hasExpression()) { if (!value.canConvert(QVariant::Int)) return; int val = value.toInt(); @@ -667,13 +669,12 @@ QWidget* PropertyIntegerItem::createEditor(QWidget* parent, const QObject* recei sb->setFrame(false); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(int)), receiver, method); - - if(isBound()) { + + if (isBound()) { sb->bind(getPath()); sb->setAutoApply(autoApply()); } - return sb; } @@ -690,12 +691,13 @@ QVariant PropertyIntegerItem::editorData(QWidget *editor) const return QVariant(sb->value()); } -QVariant PropertyIntegerItem::toString(const QVariant& v) const { +QVariant PropertyIntegerItem::toString(const QVariant& v) const +{ QString string(PropertyItem::toString(v).toString()); - - if(hasExpression()) + + if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - + return QVariant(string); } @@ -719,7 +721,7 @@ QVariant PropertyIntegerConstraintItem::value(const App::Property* prop) const void PropertyIntegerConstraintItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code - if(!hasExpression()) { + if (!hasExpression()) { if (!value.canConvert(QVariant::Int)) return; int val = value.toInt(); @@ -734,12 +736,12 @@ QWidget* PropertyIntegerConstraintItem::createEditor(QWidget* parent, const QObj sb->setFrame(false); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(int)), receiver, method); - - if(isBound()) { + + if (isBound()) { sb->bind(getPath()); sb->setAutoApply(autoApply()); - } - + } + return sb; } @@ -772,13 +774,13 @@ QVariant PropertyIntegerConstraintItem::editorData(QWidget *editor) const return QVariant(sb->value()); } -QVariant PropertyIntegerConstraintItem::toString(const QVariant& v) const { - +QVariant PropertyIntegerConstraintItem::toString(const QVariant& v) const +{ QString string(PropertyItem::toString(v).toString()); - - if(hasExpression()) + + if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - + return QVariant(string); } @@ -795,10 +797,10 @@ QVariant PropertyFloatItem::toString(const QVariant& prop) const { double value = prop.toDouble(); QString data = QLocale::system().toString(value, 'f', decimals()); - - if(hasExpression()) + + if (hasExpression()) data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - + return QVariant(data); } @@ -813,7 +815,7 @@ QVariant PropertyFloatItem::value(const App::Property* prop) const void PropertyFloatItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code - if(!hasExpression()) { + if (!hasExpression()) { if (!value.canConvert(QVariant::Double)) return; double val = value.toDouble(); @@ -829,12 +831,12 @@ QWidget* PropertyFloatItem::createEditor(QWidget* parent, const QObject* receive sb->setDecimals(decimals()); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(double)), receiver, method); - - if(isBound()) { + + if (isBound()) { sb->bind(getPath()); sb->setAutoApply(autoApply()); } - + return sb; } @@ -864,9 +866,9 @@ QVariant PropertyUnitItem::toString(const QVariant& prop) const { const Base::Quantity& unit = prop.value(); QString string = unit.getUserString(); - if(hasExpression()) + if (hasExpression()) string += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); - + return QVariant(string); } @@ -881,7 +883,7 @@ QVariant PropertyUnitItem::value(const App::Property* prop) const void PropertyUnitItem::setValue(const QVariant& value) { //if the item has an expression it handles the python code - if(!hasExpression()) { + if (!hasExpression()) { if (!value.canConvert()) return; const Base::Quantity& val = value.value(); @@ -899,7 +901,7 @@ QWidget* PropertyUnitItem::createEditor(QWidget* parent, const QObject* receiver infield->setReadOnly(isReadOnly()); //if we are bound to an expression we need to bind it to the input field - if(isBound()) { + if (isBound()) { infield->bind(getPath()); infield->setAutoApply(autoApply()); } @@ -988,7 +990,7 @@ QVariant PropertyFloatConstraintItem::value(const App::Property* prop) const void PropertyFloatConstraintItem::setValue(const QVariant& value) { //if the item has an expression it issues the python code - if(!hasExpression()) { + if (!hasExpression()) { if (!value.canConvert(QVariant::Double)) return; double val = value.toDouble(); @@ -1004,13 +1006,12 @@ QWidget* PropertyFloatConstraintItem::createEditor(QWidget* parent, const QObjec sb->setFrame(false); sb->setReadOnly(isReadOnly()); QObject::connect(sb, SIGNAL(valueChanged(double)), receiver, method); - - if(isBound()) { + + if (isBound()) { sb->bind(getPath()); sb->setAutoApply(autoApply()); } - return sb; } @@ -1248,14 +1249,13 @@ void PropertyVectorItem::setZ(double z) setData(QVariant::fromValue(Base::Vector3d(x(), y(), z))); } -void PropertyVectorItem::propertyBound() { - +void PropertyVectorItem::propertyBound() +{ m_x->bind(App::ObjectIdentifier(getPath())<bind(App::ObjectIdentifier(getPath())<bind(App::ObjectIdentifier(getPath())<bind(App::ObjectIdentifier(getPath())<bind(App::ObjectIdentifier(getPath())<bind(App::ObjectIdentifier(getPath())<value(); } -void PropertyPlacementItem::propertyBound() { - - if(isBound()) { +void PropertyPlacementItem::propertyBound() +{ + if (isBound()) { m_a->bind(App::ObjectIdentifier(getPath())<