correct Unit::Work conversions
- also add conversions for Unit::Mass and Unit::Power
This commit is contained in:
@@ -124,10 +124,26 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
|
||||
factor = 1.0;
|
||||
}
|
||||
else if (unit == Unit::Mass) {
|
||||
// TODO Cascade for the weights
|
||||
// default action for all cases without special treatment:
|
||||
unitString = quant.getUnit().getString();
|
||||
factor = 1.0;
|
||||
if (UnitValue < 1e-6) {
|
||||
unitString = QString::fromUtf8("\xC2\xB5g");
|
||||
factor = 1e-9;
|
||||
}
|
||||
else if (UnitValue < 1e-3) {
|
||||
unitString = QString::fromLatin1("mg");
|
||||
factor = 1e-6;
|
||||
}
|
||||
else if (UnitValue < 1.0) {
|
||||
unitString = QString::fromLatin1("g");
|
||||
factor = 1e-3;
|
||||
}
|
||||
else if (UnitValue < 1e3) {
|
||||
unitString = QString::fromLatin1("kg");
|
||||
factor = 1.0;
|
||||
}
|
||||
else {
|
||||
unitString = QString::fromLatin1("t");
|
||||
factor = 1e3;
|
||||
}
|
||||
}
|
||||
else if (unit == Unit::Density) {
|
||||
if (UnitValue < 0.0001) {
|
||||
@@ -234,7 +250,11 @@ QString UnitsSchemaInternal::schemaTranslate(const Quantity &quant, double &fact
|
||||
unitString = QString::fromLatin1("kJ");
|
||||
factor = 1e9;
|
||||
}
|
||||
else { // bigger than 1000 kJ -> scientific notation
|
||||
else if (UnitValue < 3.6e+15) {
|
||||
unitString = QString::fromLatin1("kWh");
|
||||
factor = 3.6e+12;
|
||||
}
|
||||
else { // bigger than 1000 kWh -> scientific notation
|
||||
unitString = QString::fromLatin1("J");
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user