Skip to content

Commit

Permalink
+ fix a couple of issues with InputField used in property editor
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 14, 2014
1 parent 00e041f commit bfae053
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Gui/InputField.cpp
Expand Up @@ -111,8 +111,9 @@ QPixmap InputField::getValidationIcon(const char* name, const QSize& size) const
void InputField::updateText(const Base::Quantity& quant)
{
double dFactor;
QString unit;
setText(quant.getUserString(dFactor,unit));
QString txt = quant.getUserString(dFactor,actUnitStr);
actUnitValue = quant.getValue()/dFactor;
setText(txt);
}

void InputField::resizeEvent(QResizeEvent *)
Expand Down Expand Up @@ -517,6 +518,7 @@ void InputField::wheelEvent (QWheelEvent * event)
val = Minimum;

this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr));
selectNumber();
event->accept();
}

Expand Down
7 changes: 7 additions & 0 deletions src/Gui/propertyeditor/PropertyModel.cpp
Expand Up @@ -89,6 +89,13 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in
if (fabs(d-v) > FLT_EPSILON)
return item->setData(value);
}
// Special case handling for quantities
else if (data.canConvert<Base::Quantity>() && value.canConvert<Base::Quantity>()) {
const Base::Quantity& val1 = data.value<Base::Quantity>();
const Base::Quantity& val2 = value.value<Base::Quantity>();
if (!(val1 == val2))
return item->setData(value);
}
else if (data != value)
return item->setData(value);
}
Expand Down

0 comments on commit bfae053

Please sign in to comment.