mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-17 16:38:20 -05:00
bd0ae24aba
More consistent and accurate processing of compund callsigns including recognizing the user's call in both base and fully qualified form, extracting reports from special type one and type two compound call messages. Ensure that "CQ DX" message prefixes are recognized and processd correctly. The cycle of double clicking through a QSO has been enhanced to recognoize the standard messages correctly and use the correct next message. The automatic transmission button "Enable Tx" now does what it says and does not double as a stop transmit button. This allows the current transmission to complete even if the automatic transmission feature is disabled. In line with this the "stop sending after a 73 message is sent" feature turns off the automatic transmission enable at the start of the sending of a 73 message and also the next message is now set up as the CQ message automatically in this scenario. A 73 message is now either a standard message containing the word "73" or any free text message containing "73" (not necessarily as a distinct word"). git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5055 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
108 lines
2.7 KiB
C++
108 lines
2.7 KiB
C++
#include "Radio.hpp"
|
|
|
|
#include <cmath>
|
|
|
|
#include <QMetaType>
|
|
#include <QString>
|
|
#include <QChar>
|
|
#include <QDebug>
|
|
#include <QRegExpValidator>
|
|
#include <QDataStream>
|
|
#include <QRegularExpression>
|
|
|
|
namespace Radio
|
|
{
|
|
namespace
|
|
{
|
|
struct init
|
|
{
|
|
init ()
|
|
{
|
|
qRegisterMetaType<Frequency> ("Frequency");
|
|
|
|
qRegisterMetaType<Frequencies> ("Frequencies");
|
|
qRegisterMetaTypeStreamOperators<Frequencies> ("Frequencies");
|
|
|
|
qRegisterMetaType<FrequencyDelta> ("FrequencyDelta");
|
|
}
|
|
} static_initaializer;
|
|
|
|
double constexpr MHz_factor {1.e6};
|
|
int constexpr frequency_precsion {6};
|
|
|
|
// very loose validation - callsign must contain a letter next to
|
|
// a number
|
|
QRegularExpression valid_callsign_regexp {R"(\d[[:alpha:]]|[[:alpha:]]\d)"};
|
|
}
|
|
|
|
|
|
Frequency frequency (QVariant const& v, int scale)
|
|
{
|
|
return std::llround (v.toDouble () * std::pow (10., scale));
|
|
}
|
|
|
|
FrequencyDelta frequency_delta (QVariant const& v, int scale)
|
|
{
|
|
return std::llround (v.toDouble () * std::pow (10., scale));
|
|
}
|
|
|
|
|
|
QString frequency_MHz_string (Frequency f, QLocale const& locale)
|
|
{
|
|
return locale.toString (f / MHz_factor, 'f', frequency_precsion);
|
|
}
|
|
|
|
QString frequency_MHz_string (FrequencyDelta d, QLocale const& locale)
|
|
{
|
|
return locale.toString (d / MHz_factor, 'f', frequency_precsion);
|
|
}
|
|
|
|
QString pretty_frequency_MHz_string (Frequency f, QLocale const& locale)
|
|
{
|
|
auto f_string = locale.toString (f / MHz_factor, 'f', frequency_precsion);
|
|
return f_string.insert (f_string.size () - 3, QChar::Nbsp);
|
|
}
|
|
|
|
QString pretty_frequency_MHz_string (double f, int scale, QLocale const& locale)
|
|
{
|
|
auto f_string = locale.toString (f / std::pow (10., scale - 6), 'f', frequency_precsion);
|
|
return f_string.insert (f_string.size () - 3, QChar::Nbsp);
|
|
}
|
|
|
|
QString pretty_frequency_MHz_string (FrequencyDelta d, QLocale const& locale)
|
|
{
|
|
auto d_string = locale.toString (d / MHz_factor, 'f', frequency_precsion);
|
|
return d_string.insert (d_string.size () - 3, QChar::Nbsp);
|
|
}
|
|
|
|
bool is_callsign (QString const& callsign)
|
|
{
|
|
return callsign.contains (valid_callsign_regexp);
|
|
}
|
|
|
|
bool is_compound_callsign (QString const& callsign)
|
|
{
|
|
return callsign.contains ('/');
|
|
}
|
|
|
|
// split on first '/' and return the larger portion or the whole if
|
|
// there is no '/'
|
|
QString base_callsign (QString callsign)
|
|
{
|
|
auto slash_pos = callsign.indexOf ('/');
|
|
if (slash_pos >= 0)
|
|
{
|
|
auto right_size = callsign.size () - slash_pos - 1;
|
|
if (right_size>= slash_pos)
|
|
{
|
|
callsign = callsign.mid (slash_pos + 1);
|
|
}
|
|
else
|
|
{
|
|
callsign = callsign.left (slash_pos);
|
|
}
|
|
}
|
|
return callsign;
|
|
}
|
|
}
|