| 75 | } |
| 76 | |
| 77 | bool DoubleScrubber::commitText(const QString& text) { |
| 78 | QString stripped = text; |
| 79 | if (!prefix_.isEmpty() && stripped.startsWith(prefix_)) { |
| 80 | stripped = stripped.mid(prefix_.size()); |
| 81 | } |
| 82 | if (!suffix_.isEmpty() && stripped.endsWith(suffix_)) { |
| 83 | stripped.chop(suffix_.size()); |
| 84 | } |
| 85 | bool ok = false; |
| 86 | const double parsed = stripped.trimmed().toDouble(&ok); |
| 87 | if (!ok) { |
| 88 | return false; |
| 89 | } |
| 90 | setValue(parsed); |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | } // namespace PJ |