diff options
| author | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:49 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-10-09 14:12:49 +0200 |
| commit | 76956486fa7ef52a51d4e56df1e13a9f19a6c93c (patch) | |
| tree | fe0c394439fdc167d1970372e8998874090854dd /Radio.cpp | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
| parent | ffc62c792c9a5196cb4ce7a353287dfe20db6524 (diff) | |
Update upstream source from tag 'upstream/3.3.0_beta1+dfsg'
Update to upstream version '3.3.0~beta1+dfsg'
with Debian dir 85037bbb9376721108594b59b54ead82ac6924a3
Diffstat (limited to 'Radio.cpp')
| -rw-r--r-- | Radio.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
@@ -27,6 +27,18 @@ namespace Radio // suffixes that are often used and should not be interpreted as a // DXCC Entity prefix used as a suffix QRegularExpression non_prefix_suffix {R"(\A([0-9AMPQR]|QRP|F[DF]|[AM]M|L[HT]|LGT)\z)"}; + + QString callsign_without_operating_suffixes (QString callsign) + { + callsign = callsign.toUpper (); + auto slash_pos = callsign.lastIndexOf ('/'); + while (slash_pos >= 0 && callsign.mid (slash_pos + 1).contains (non_prefix_suffix)) + { + callsign.truncate (slash_pos); + slash_pos = callsign.lastIndexOf ('/'); + } + return callsign; + } } @@ -129,6 +141,25 @@ namespace Radio return d_string.insert (d_string.size () - 3, QChar::Nbsp); } + bool is_standard_callsign (QString const& w) + { + static QRegularExpression standard_call_re { + R"( + ^\s* # optional leading spaces + ( [A-Z]{0,2} | [A-Z][0-9] | [0-9][A-Z] ) # part 1 + ( [0-9][A-Z]{0,3} ) # part 2 + (/R | /P)? # optional suffix + \s*$ # optional trailing spaces + )", QRegularExpression::CaseInsensitiveOption | QRegularExpression::ExtendedPatternSyntaxOption}; + return standard_call_re.match (w).hasMatch (); + } + + QRegularExpression const& decoded_grid_pattern () + { + static QRegularExpression const pattern {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; + return pattern; + } + bool is_callsign (QString const& callsign) { return callsign.contains (valid_callsign_regexp); @@ -145,10 +176,10 @@ namespace Radio && !callsign.contains (strict_standard_callsign_re); } - // split on first '/' and return the larger portion or the whole if - // there is no '/' + // Ignore operating suffixes and return the larger callsign component. QString base_callsign (QString callsign) { + callsign = callsign_without_operating_suffixes (callsign); auto slash_pos = callsign.indexOf ('/'); if (slash_pos >= 0) { @@ -162,13 +193,14 @@ namespace Radio callsign = callsign.left (slash_pos); } } - return callsign.toUpper (); + return callsign; } // analyze the callsign and determine the effective prefix, returns // the full call if no valid prefix (or prefix as a suffix) is specified QString effective_prefix (QString callsign) { + callsign = callsign_without_operating_suffixes (callsign); auto prefix = callsign; auto slash_pos = callsign.indexOf ('/'); if (slash_pos >= 0) @@ -182,14 +214,8 @@ namespace Radio else { prefix = callsign.mid (slash_pos + 1); - if (prefix.contains (non_prefix_suffix)) - { - prefix = callsign.left (slash_pos); // ignore - // non-prefix - // suffixes - } } } - return prefix.toUpper (); + return prefix; } } |
