| 682 | } |
| 683 | |
| 684 | void InputField::focusOutEvent(QFocusEvent* event) |
| 685 | { |
| 686 | try { |
| 687 | if (Quantity::parse(this->text().toStdString()).isDimensionless()) { |
| 688 | // if user didn't enter a unit, we virtually compensate |
| 689 | // the multiplication factor induced by user unit system |
| 690 | double factor; |
| 691 | std::string unitStr; |
| 692 | actQuantity.getUserString(factor, unitStr); |
| 693 | actQuantity = actQuantity * factor; |
| 694 | } |
| 695 | } |
| 696 | catch (const Base::ParserError&) { |
| 697 | // do nothing, let apply the last known good value |
| 698 | } |
| 699 | this->setText(QString::fromStdString(actQuantity.getUserString())); |
| 700 | QLineEdit::focusOutEvent(event); |
| 701 | } |
| 702 | |
| 703 | void InputField::keyPressEvent(QKeyEvent* event) |
| 704 | { |
nothing calls this directly
no test coverage detected