simplify handling of locale specific with InputField from Python

This commit is contained in:
wmayer
2019-01-17 02:57:00 +01:00
parent fdf8fe7bc6
commit 0cc8efa105
3 changed files with 29 additions and 3 deletions

View File

@@ -457,6 +457,25 @@ void InputField::setQuantityString(const QString& text)
updateText(actQuantity);
}
/// return the quantity in C locale, i.e. decimal separator is a dot.
QString InputField::rawText(void) const
{
double factor;
QString unit;
double value = actQuantity.getValue();
actQuantity.getUserString(factor, unit);
return QString::fromLatin1("%1 %2").arg(value / factor).arg(unit);
}
/// expects the string in C locale and internally converts it into the OS-specific locale
void InputField::setRawText(const QString& text)
{
Base::Quantity quant = Base::Quantity::parse(text);
// Input and then format the quantity
newInput(quant.getUserString());
updateText(actQuantity);
}
/// get the value of the singleStep property
double InputField::singleStep(void)const
{