diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
| commit | 37f727ac0746fd85504aa46c1f023c09b3eff33a (patch) | |
| tree | c8a7ce04545040a8f161ba279528730bd9a3e6ab /CallsignValidator.cpp | |
| parent | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff) | |
New upstream version 1.8.0+repackupstream/1.8.0+repack
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; +} |
