Spreadsheet: support displaying of integer

This commit is contained in:
Zheng, Lei
2019-12-26 19:03:41 +08:00
committed by Chris Hennes
parent 93beb9fabd
commit ec27c67dc0

View File

@@ -392,10 +392,15 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
{
/* Number */
double d;
long l;
bool isInteger = false;
if(prop->isDerivedFrom(App::PropertyFloat::getClassTypeId()))
d = static_cast<const App::PropertyFloat*>(prop)->getValue();
else
d = static_cast<const App::PropertyInteger*>(prop)->getValue();
else {
isInteger = true;
l = static_cast<const App::PropertyInteger*>(prop)->getValue();
d = l;
}
switch (role) {
case Qt::ForegroundRole: {
@@ -431,10 +436,11 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
//QString number = QString::number(d / displayUnit.scaler);
v = number + Base::Tools::fromStdString(" " + displayUnit.stringRep);
}
else {
v = QLocale().toString(d,'f',Base::UnitsApi::getDecimals());
else if (!isInteger) {
v = QLocale::system().toString(d,'f',Base::UnitsApi::getDecimals());
//v = QString::number(d);
}
} else
v = QString::number(l);
return QVariant(v);
}
default: