diff --git a/apps/calculation/additional_outputs/unit_list_controller.cpp b/apps/calculation/additional_outputs/unit_list_controller.cpp index a288bdca8..d43ece851 100644 --- a/apps/calculation/additional_outputs/unit_list_controller.cpp +++ b/apps/calculation/additional_outputs/unit_list_controller.cpp @@ -21,6 +21,7 @@ void UnitListController::computeLayoutAtIndex(int index) { //FIXME // SI units only Shared::PoincareHelpers::Simplify(&expressionAtIndex, App::app()->localContext(), ExpressionNode::ReductionTarget::User, Poincare::ExpressionNode::SymbolicComputation::ReplaceAllDefinedSymbolsWithDefinition, Poincare::ExpressionNode::UnitConversion::InternationalSystem); } else if (index == 1) { + // Miscellaneous classic units for some dimensions ExpressionNode::ReductionContext reductionContext( App::app()->localContext(), Preferences::sharedPreferences()->complexFormat(), @@ -31,9 +32,10 @@ void UnitListController::computeLayoutAtIndex(int index) { //FIXME // Reduce to be able to recognize units expressionAtIndex = expressionAtIndex.reduce(reductionContext); expressionAtIndex = expressionAtIndex.removeUnit(&units); - bool requireSimplification = true; - bool canChangeUnitPrefix = true; + bool requireSimplification = false; + bool canChangeUnitPrefix = false; if (Unit::IsISSpeed(units)) { + // Turn into km/h expressionAtIndex = UnitConvert::Builder( m_expression.clone(), Multiplication::Builder( @@ -44,13 +46,17 @@ void UnitListController::computeLayoutAtIndex(int index) { //FIXME ) ) ); - canChangeUnitPrefix = false; // We force km/h + requireSimplification = true; // Reduce the conversion } else if (Unit::IsISVolume(units)) { + // Turn into L expressionAtIndex = UnitConvert::Builder( m_expression.clone(), Unit::Liter() ); + requireSimplification = true; // reduce the conversion + canChangeUnitPrefix = true; // Pick best prefix (mL) } else if (Unit::IsISEnergy(units)) { + // Turn into W expressionAtIndex = UnitConvert::Builder( m_expression.clone(), Multiplication::Builder( @@ -58,16 +64,13 @@ void UnitListController::computeLayoutAtIndex(int index) { //FIXME Unit::Hour() ) ); + requireSimplification = true; // reduce the conversion + canChangeUnitPrefix = true; // Pick best prefix (kWh) } else if (Unit::IsISTime(units)) { + // Turn into ? year + ? month + ? day + ? h + ? min + ? s double value = Shared::PoincareHelpers::ApproximateToScalar(expressionAtIndex, App::app()->localContext()); expressionAtIndex = Unit::BuildTimeSplit(value); - requireSimplification = false; - canChangeUnitPrefix = false; - } else { - requireSimplification = false; - canChangeUnitPrefix = false; } - if (requireSimplification) { Shared::PoincareHelpers::Simplify(&expressionAtIndex, App::app()->localContext(), ExpressionNode::ReductionTarget::User); } diff --git a/apps/calculation/calculation.cpp b/apps/calculation/calculation.cpp index 3393e9f2e..abcafd696 100644 --- a/apps/calculation/calculation.cpp +++ b/apps/calculation/calculation.cpp @@ -250,7 +250,7 @@ Calculation::AdditionalInformationType Calculation::additionalInformationType(Co if (input().isDefinedCosineOrSine(context, complexFormat, preferences->angleUnit()) || o.isDefinedCosineOrSine(context, complexFormat, preferences->angleUnit())) { return AdditionalInformationType::Trigonometry; } - if (o.hasUnit()) { + if (o.hasUnit()) { // TODO: find a way to check that it'll do have additional results return AdditionalInformationType::Unit; } if (o.isBasedIntegerCappedBy(k_maximalIntegerWithAdditionalInformation)) {