[SS]Fix Integer Formatted Value

This commit is contained in:
wandererfan
2019-10-01 15:54:10 -04:00
committed by WandererFan
parent ff5a9783d4
commit bed78b0b7b

View File

@@ -992,14 +992,8 @@ std::string Cell::getFormattedQuantity(void)
}
}
} else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()) ||
prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
double rawVal;
if(prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
rawVal = static_cast<const App::PropertyFloat*>(prop)->getValue();
} else {
rawVal = static_cast<const App::PropertyInteger*>(prop)->getValue();
}
} else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())){
double rawVal = static_cast<const App::PropertyFloat*>(prop)->getValue();
DisplayUnit du;
bool hasDisplayUnit = getDisplayUnit(du);
double duScale = du.scaler;
@@ -1008,6 +1002,17 @@ std::string Cell::getFormattedQuantity(void)
QString number = QLocale::system().toString(rawVal / duScale, 'f',Base::UnitsApi::getDecimals());
qFormatted = number + Base::Tools::fromStdString(" " + displayUnit.stringRep);
}
} else if (prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
double rawVal = static_cast<const App::PropertyInteger*>(prop)->getValue();
DisplayUnit du;
bool hasDisplayUnit = getDisplayUnit(du);
double duScale = du.scaler;
int iRawVal = std::round(rawVal);
qFormatted = QLocale::system().toString(iRawVal);
if (hasDisplayUnit) {
QString number = QLocale::system().toString(rawVal / duScale, 'f',Base::UnitsApi::getDecimals());
qFormatted = number + Base::Tools::fromStdString(" " + displayUnit.stringRep);
}
}
result = Base::Tools::toStdString(qFormatted);
return result;