fixes 0003726: Property Editor Angle Fields Do Not Respect Units

This commit is contained in:
wmayer
2018-12-16 21:35:58 +01:00
parent 07b070c8c6
commit 046e8e0444
2 changed files with 3 additions and 27 deletions

View File

@@ -1064,36 +1064,12 @@ PropertyAngleItem::PropertyAngleItem()
void PropertyAngleItem::setEditorData(QWidget *editor, const QVariant& data) const
{
const App::PropertyQuantityConstraint* prop = static_cast
<const App::PropertyQuantityConstraint*>(getFirstProperty());
const App::PropertyQuantityConstraint::Constraints* c = 0;
if (prop) {
c = prop->getConstraints();
}
QDoubleSpinBox *sb = qobject_cast<QDoubleSpinBox*>(editor);
if (c) {
sb->setMinimum(c->LowerBound);
sb->setMaximum(c->UpperBound);
sb->setSingleStep(c->StepSize);
}
else {
sb->setMinimum((double)INT_MIN);
sb->setMaximum((double)INT_MAX);
sb->setSingleStep(1.0);
}
sb->setValue(data.toDouble());
sb->setSuffix(QString::fromUtf8(" \xc2\xb0"));
PropertyUnitConstraintItem::setEditorData(editor, data);
}
QVariant PropertyAngleItem::toString(const QVariant& prop) const
{
double value = prop.toDouble();
QString data = QString::fromUtf8("%1 \xc2\xb0")
.arg(QLocale::system().toString(value, 'f', decimals()));
return QVariant(data);
return PropertyUnitConstraintItem::toString(prop);
}
// --------------------------------------------------------------------

View File

@@ -375,7 +375,7 @@ protected:
* Change a floating point number.
* \author Werner Mayer
*/
class GuiExport PropertyAngleItem : public PropertyFloatItem
class GuiExport PropertyAngleItem : public PropertyUnitConstraintItem
{
Q_OBJECT
PROPERTYITEM_HEADER