summaryrefslogtreecommitdiff
path: root/validators
diff options
context:
space:
mode:
Diffstat (limited to 'validators')
-rw-r--r--validators/CallsignValidator.cpp14
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 ();