mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-24 13:18:38 -05:00
Allow but remove leading/trail white space in DX Call field
this allows pasting callsigns from the clipboard that might include them.
This commit is contained in:
parent
7455ec02c3
commit
823afde91a
@ -2,14 +2,24 @@
|
|||||||
|
|
||||||
CallsignValidator::CallsignValidator (QObject * parent, bool allow_compound)
|
CallsignValidator::CallsignValidator (QObject * parent, bool allow_compound)
|
||||||
: QValidator {parent}
|
: 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 CallsignValidator::validate (QString& input, int& pos) const -> State
|
||||||
{
|
{
|
||||||
auto match = re_.match (input, 0, QRegularExpression::PartialPreferCompleteMatch);
|
|
||||||
input = input.toUpper ();
|
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 (match.hasMatch ()) return Acceptable;
|
||||||
if (!input.size () || match.hasPartialMatch ()) return Intermediate;
|
if (!input.size () || match.hasPartialMatch ()) return Intermediate;
|
||||||
pos = input.size ();
|
pos = input.size ();
|
||||||
|
Loading…
Reference in New Issue
Block a user