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:
@@ -278,11 +278,11 @@ void InputField::newInput(const QString & text)
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.getUnit().isEmpty())
|
||||
if (res.isDimensionless())
|
||||
res.setUnit(this->actUnit);
|
||||
|
||||
// check if unit fits!
|
||||
if(!actUnit.isEmpty() && !res.getUnit().isEmpty() && actUnit != res.getUnit()){
|
||||
if (!actUnit.isEmpty() && !res.isDimensionless() && actUnit != res.getUnit()){
|
||||
if (iconLabel->isHidden()) {
|
||||
iconLabel->setVisible(true);
|
||||
}
|
||||
@@ -644,7 +644,7 @@ void InputField::focusInEvent(QFocusEvent *event)
|
||||
void InputField::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
try {
|
||||
if (Quantity::parse(this->text().toStdString()).getUnit().isEmpty()) {
|
||||
if (Quantity::parse(this->text().toStdString()).isDimensionless()) {
|
||||
// if user didn't enter a unit, we virtually compensate
|
||||
// the multiplication factor induced by user unit system
|
||||
double factor;
|
||||
|
||||
Reference in New Issue
Block a user