diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:18:44 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:18:44 +0000 |
| commit | 368f5331a7641772aa7e0cd1feea57d09a394a36 (patch) | |
| tree | b421ac60cc6eb726896ea268ea24e47fc4ce7c88 /CallsignValidator.cpp | |
| parent | 71c717edc92fa771c857b3c2e5ed65f523f68f90 (diff) | |
| parent | 37f727ac0746fd85504aa46c1f023c09b3eff33a (diff) | |
Update upstream source from tag 'upstream/1.8.0+repack'
Update to upstream version '1.8.0+repack'
with Debian dir a83ef78cb70a32d1211871fdc08f3ffa295e45a8
Diffstat (limited to 'CallsignValidator.cpp')
| -rw-r--r-- | CallsignValidator.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/CallsignValidator.cpp b/CallsignValidator.cpp new file mode 100644 index 00000000..ddcd64f1 --- /dev/null +++ b/CallsignValidator.cpp @@ -0,0 +1,17 @@ +#include "CallsignValidator.hpp" + +CallsignValidator::CallsignValidator (QObject * parent, bool allow_compound) + : QValidator {parent} + , re_ {allow_compound ? R"(^[A-Za-z0-9/]+$)" : R"(^[A-Za-z0-9]+$)"} +{ +} + +auto CallsignValidator::validate (QString& input, int& pos) const -> State +{ + auto match = re_.match (input, 0, QRegularExpression::PartialPreferCompleteMatch); + input = input.toUpper (); + if (match.hasMatch ()) return Acceptable; + if (!input.size () || match.hasPartialMatch ()) return Intermediate; + pos = input.size (); + return Invalid; +} |
