Skip to content

Commit

Permalink
Spreadsheet: [skip ci] use global scheme to display quantities in a s…
Browse files Browse the repository at this point in the history
…preadsheet table
  • Loading branch information
wwmayer committed Sep 9, 2020
1 parent be42d1b commit 556630f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Mod/Spreadsheet/Gui/SheetModel.cpp
Expand Up @@ -90,6 +90,7 @@ static void appendUnit(int l, bool isNumerator, std::string unit, std::vector<st
}
}

#if 0 // obsolete function
static std::string getUnitString(const Base::Unit & unit)
{
std::vector<std::string> numerator;
Expand Down Expand Up @@ -144,6 +145,7 @@ static std::string getUnitString(const Base::Unit & unit)

return unitStr;
}
#endif

QVariant SheetModel::data(const QModelIndex &index, int role) const
{
Expand Down Expand Up @@ -371,12 +373,16 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const
}
}
else {
QString number = QLocale().toString(floatProp->getValue(),'f',Base::UnitsApi::getDecimals());
//QString number = QString::number(floatProp->getValue());
if (!computedUnit.isEmpty())
v = number + Base::Tools::fromStdString(" " + getUnitString(computedUnit));
else
v = number;
//QString number = QLocale().toString(floatProp->getValue(),'f',Base::UnitsApi::getDecimals());
//if (!computedUnit.isEmpty())
// v = number + Base::Tools::fromStdString(" " + getUnitString(computedUnit));
//else
// v = number;

// When displaying a quantity then use the globally set scheme
// See: https://forum.freecadweb.org/viewtopic.php?f=3&t=50078
Base::Quantity value = floatProp->getQuantityValue();
v = value.getUserString();
}

return QVariant(v);
Expand Down

0 comments on commit 556630f

Please sign in to comment.