| 69 | } |
| 70 | |
| 71 | bool IntScrubber::commitText(const QString& text) { |
| 72 | QString stripped = text; |
| 73 | if (!prefix_.isEmpty() && stripped.startsWith(prefix_)) { |
| 74 | stripped = stripped.mid(prefix_.size()); |
| 75 | } |
| 76 | if (!suffix_.isEmpty() && stripped.endsWith(suffix_)) { |
| 77 | stripped.chop(suffix_.size()); |
| 78 | } |
| 79 | bool ok = false; |
| 80 | const int parsed = stripped.trimmed().toInt(&ok); |
| 81 | if (!ok) { |
| 82 | return false; |
| 83 | } |
| 84 | setValue(parsed); |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | } // namespace PJ |