From 37f727ac0746fd85504aa46c1f023c09b3eff33a Mon Sep 17 00:00:00 2001 From: hibby Date: Fri, 16 Feb 2018 15:17:14 +0000 Subject: New upstream version 1.8.0+repack --- CallsignValidator.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 CallsignValidator.cpp (limited to 'CallsignValidator.cpp') 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; +} -- cgit v1.2.3