Base: Quantity: use isDimensionless whenever feasible

Quantity is often queried for Unit just to see if it has a dimension.
Ask Quantity directly using isDimensionless() method and modify that
method not to care about Quantity value validity; no user was ever
asking for value validity.
This commit is contained in:
Ladislav Michl
2025-04-10 17:43:41 +02:00
parent 6c4880782e
commit 0c9584ab2d
10 changed files with 31 additions and 58 deletions

View File

@@ -295,13 +295,13 @@ void DlgExpressionInput::checkExpression(const QString& text)
auto msg = value.getUserString();
if (!impliedUnit.isEmpty()) {
if (!value.getUnit().isEmpty() && value.getUnit() != impliedUnit)
if (!value.isDimensionless() && value.getUnit() != impliedUnit)
throw Base::UnitsMismatchError("Unit mismatch between result and required unit");
value.setUnit(impliedUnit);
}
else if (!value.getUnit().isEmpty()) {
else if (!value.isDimensionless()) {
msg += " (Warning: unit discarded)";
QPalette p(ui->msg->palette());