diff options
| author | Christoph Berg <myon@debian.org> | 2018-12-19 23:01:50 +0100 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2018-12-19 23:01:50 +0100 |
| commit | 5c60c77adff9a54fd5f94f9915b22ccd8c4c5a3b (patch) | |
| tree | 410fa358a5f73260a579b4d669730f319a4d2609 /Radio.cpp | |
| parent | 6c82050de806dcdafaed0077400a6c3396a4a159 (diff) | |
| parent | e0737c56c1e384e05064a0c6e1ac46979371041b (diff) | |
Update upstream source from tag 'upstream/2.0.0+repack'
Update to upstream version '2.0.0+repack'
with Debian dir 55dbb3a6a7eb189e187dd79f732623ca0b56116d
Diffstat (limited to 'Radio.cpp')
| -rw-r--r-- | Radio.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -17,6 +17,10 @@ namespace Radio // very loose validation - callsign must contain a letter next to // a number QRegularExpression valid_callsign_regexp {R"(\d[[:alpha:]]|[[:alpha:]]\d)"}; + + // 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)"}; } @@ -125,6 +129,34 @@ namespace Radio callsign = callsign.left (slash_pos); } } - return callsign; + return callsign.toUpper (); + } + + // 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) + { + auto prefix = callsign; + auto slash_pos = callsign.indexOf ('/'); + if (slash_pos >= 0) + { + auto right_size = callsign.size () - slash_pos - 1; + if (right_size >= slash_pos) // native call is longer than + // prefix/suffix algorithm + { + prefix = callsign.left (slash_pos); + } + 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 (); } } |
