Base: Units: introduce unit one
Dimensionless quantities have all exponents equal to zero. Such quantities are simply numbers. The associated unit is the unit one, symbol 1, although this is rarely explicitly written. See chapter 2.3.3 Dimensions of quantities, The International System of Units, 9th edition.
This commit is contained in:
@@ -607,7 +607,7 @@ void Cell::setComputedUnit(const Base::Unit& unit)
|
||||
PropertySheet::AtomicPropertyChange signaller(*owner);
|
||||
|
||||
computedUnit = unit;
|
||||
setUsed(COMPUTED_UNIT_SET, !computedUnit.isEmpty());
|
||||
setUsed(COMPUTED_UNIT_SET, computedUnit != Unit::One);
|
||||
setDirty();
|
||||
|
||||
signaller.tryInvoke();
|
||||
@@ -1110,7 +1110,7 @@ std::string Cell::getFormattedQuantity()
|
||||
const Base::Unit& computedUnit = floatProp->getUnit();
|
||||
qFormatted = QLocale().toString(rawVal, 'f', Base::UnitsApi::getDecimals());
|
||||
if (hasDisplayUnit) {
|
||||
if (computedUnit.isEmpty() || computedUnit == du.unit) {
|
||||
if (computedUnit == Unit::One || computedUnit == du.unit) {
|
||||
QString number =
|
||||
QLocale().toString(rawVal / duScale, 'f', Base::UnitsApi::getDecimals());
|
||||
qFormatted = number + QString::fromStdString(" " + displayUnit.stringRep);
|
||||
|
||||
@@ -802,7 +802,7 @@ void Sheet::updateProperty(CellAddress key)
|
||||
Base::PyGILStateLocker lock;
|
||||
setObjectProperty(key, constant->getPyValue());
|
||||
}
|
||||
else if (!number->getUnit().isEmpty()) {
|
||||
else if (number->getUnit() != Unit::One) {
|
||||
setQuantityProperty(key, number->getValue(), number->getUnit());
|
||||
}
|
||||
else if (number->isInteger(&l)) {
|
||||
|
||||
@@ -384,7 +384,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
|
||||
// Display locale specific decimal separator (#0003875,#0003876)
|
||||
if (cell->getDisplayUnit(displayUnit)) {
|
||||
if (computedUnit.isEmpty() || computedUnit == displayUnit.unit) {
|
||||
if (computedUnit == Base::Unit::One || computedUnit == displayUnit.unit) {
|
||||
QString number =
|
||||
QLocale().toString(floatProp->getValue() / displayUnit.scaler,
|
||||
'f',
|
||||
|
||||
Reference in New Issue
Block a user