Added new CQ parsing to be more intuitive

This commit is contained in:
Jordan Sherer 2018-09-18 10:53:43 -04:00
parent 1817e298b1
commit 4e094b791c
3 changed files with 21 additions and 8 deletions

View File

@ -6355,9 +6355,8 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
bool lineStartsWithBaseCall = ( bool lineStartsWithBaseCall = (
line.startsWith("ALLCALL") || line.startsWith("ALLCALL") ||
line.startsWith("CQCQCQ") || line.startsWith("BEACON") ||
line.startsWith("CQ ") || Varicode::startsWithCQ(line)
line.startsWith("BEACON")
); );
bool lineStartsWithStandardCall = !calls.isEmpty() && line.startsWith(calls.first()); bool lineStartsWithStandardCall = !calls.isEmpty() && line.startsWith(calls.first());
@ -10122,9 +10121,10 @@ void MainWindow::displayBandActivity() {
} }
textItem->setTextAlignment(flag); textItem->setTextAlignment(flag);
if (text.last().contains(QRegularExpression { if (
"\\b(CQCQCQ|CQ)\\b" Varicode::startsWithCQ(text.last()) ||
})) { text.last().contains(QRegularExpression {"\\b(CQCQCQ|CQ)\\b"})
){
offsetItem->setBackground(QBrush(m_config.color_CQ())); offsetItem->setBackground(QBrush(m_config.color_CQ()));
ageItem->setBackground(QBrush(m_config.color_CQ())); ageItem->setBackground(QBrush(m_config.color_CQ()));
snrItem->setBackground(QBrush(m_config.color_CQ())); snrItem->setBackground(QBrush(m_config.color_CQ()));
@ -10133,7 +10133,7 @@ void MainWindow::displayBandActivity() {
bool isDirectedAllCall = false; bool isDirectedAllCall = false;
// TODO: jsherer - there's a potential here for a previous allcall o poison the highlight. // TODO: jsherer - there's a potential here for a previous allcall to poison the highlight.
if ( if (
(isDirectedOffset(offset, &isDirectedAllCall) && !isDirectedAllCall) || (isDirectedOffset(offset, &isDirectedAllCall) && !isDirectedAllCall) ||
(text.last().contains(Radio::base_callsign(m_config.my_callsign()))) (text.last().contains(Radio::base_callsign(m_config.my_callsign())))

View File

@ -103,7 +103,7 @@ QRegularExpression directed_re("^" +
optional_cmd_pattern + optional_cmd_pattern +
optional_num_pattern); optional_num_pattern);
QRegularExpression beacon_re(R"(^\s*(?<type>CQCQCQ|CQ QRP|CQ DX|CQ TEST|BEACON)(?:\s(?<grid>[A-R]{2}[0-9]{2}))?\b)"); QRegularExpression beacon_re(R"(^\s*(?<type>CQCQCQ|CQ QRP|CQ DX|CQ TEST|CQ( CQ){0,2}|BEACON)(?:\s(?<grid>[A-R]{2}[0-9]{2}))?\b)");
QRegularExpression compound_re("^\\s*[<]" + QRegularExpression compound_re("^\\s*[<]" +
callsign_pattern + callsign_pattern +
@ -350,6 +350,9 @@ QMap<quint32, QString> cqs = {
{ 1, "CQ DX" }, { 1, "CQ DX" },
{ 2, "CQ QRP" }, { 2, "CQ QRP" },
{ 3, "CQ TEST" }, { 3, "CQ TEST" },
{ 4, "CQ"},
{ 5, "CQ CQ"},
{ 6, "CQ CQ CQ"},
}; };
QMap<int, int> dbm2mw = { QMap<int, int> dbm2mw = {
@ -442,6 +445,15 @@ QString Varicode::cqString(int number){
return cqs[number]; return cqs[number];
} }
bool Varicode::startsWithCQ(QString text){
foreach(auto cq, cqs.values()){
if(text.startsWith(cq)){
return true;
}
}
return false;
}
QString Varicode::formatSNR(int snr){ QString Varicode::formatSNR(int snr){
if(snr < -60 || snr > 60){ if(snr < -60 || snr > 60){
return QString(); return QString();

View File

@ -57,6 +57,7 @@ public:
//Varicode(); //Varicode();
static QString cqString(int number); static QString cqString(int number);
static bool startsWithCQ(QString text);
static QString formatSNR(int snr); static QString formatSNR(int snr);
static QString formatPWR(int dbm); static QString formatPWR(int dbm);