diff options
| author | Christoph Berg <myon@debian.org> | 2021-05-24 21:56:12 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2021-05-24 21:56:12 +0200 |
| commit | 5d6ce68ef66fcb9fa736d942b757f6b039684a8e (patch) | |
| tree | ac5434b0bb2c1610af8fd22a3d50bee3d2047cd8 /validators/CallsignValidator.cpp | |
| parent | f31b3d26dc737dcc9d2e9b8ea34690ffc669815c (diff) | |
| parent | 2f095a04ed69d9aa14b47dc4acde6b3225b2d65e (diff) | |
Update upstream source from tag 'upstream/2.4.0+repack'
Update to upstream version '2.4.0+repack'
with Debian dir 9ca745702cabe41ba6c3b1e36a86b074ebd5a230
Diffstat (limited to 'validators/CallsignValidator.cpp')
| -rw-r--r-- | validators/CallsignValidator.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/validators/CallsignValidator.cpp b/validators/CallsignValidator.cpp index ddcd64f1..d6e1bb2c 100644 --- a/validators/CallsignValidator.cpp +++ b/validators/CallsignValidator.cpp @@ -2,14 +2,24 @@ CallsignValidator::CallsignValidator (QObject * parent, bool allow_compound) : QValidator {parent} - , re_ {allow_compound ? R"(^[A-Za-z0-9/]+$)" : R"(^[A-Za-z0-9]+$)"} + , re_ {allow_compound ? R"(^[A-Z0-9/]+$)" : R"(^[A-Z0-9]+$)"} { } auto CallsignValidator::validate (QString& input, int& pos) const -> State { - auto match = re_.match (input, 0, QRegularExpression::PartialPreferCompleteMatch); input = input.toUpper (); + while (input.size () && input[0].isSpace ()) + { + input.remove (0, 1); + if (pos > 0) --pos; + } + while (input.size () && input[input.size ()].isSpace ()) + { + if (pos > input.size ()) --pos; + input.chop (1); + } + auto match = re_.match (input, 0, QRegularExpression::PartialPreferCompleteMatch); if (match.hasMatch ()) return Acceptable; if (!input.size () || match.hasPartialMatch ()) return Intermediate; pos = input.size (); |
