Updated compound call parsing and aliasing
This commit is contained in:
parent
999a239e67
commit
246d53201c
@ -3507,6 +3507,10 @@ void MainWindow::readFromStdout() //readFromStdout
|
||||
}
|
||||
|
||||
QString MainWindow::lookupCallInCompoundCache(QString const &call){
|
||||
QString myBaseCall = Radio::base_callsign(m_config.my_callsign());
|
||||
if(call == myBaseCall){
|
||||
return m_config.my_callsign();
|
||||
}
|
||||
return m_compoundCallCache.value(call, call);
|
||||
}
|
||||
|
||||
@ -5394,17 +5398,26 @@ void MainWindow::clearActivity(){
|
||||
ui->textEditRX->clear();
|
||||
ui->freeTextMsg->clear();
|
||||
ui->extFreeTextMsg->clear();
|
||||
|
||||
// make sure to clear the read only and transmitting flags so there's always a "way out"
|
||||
ui->extFreeTextMsgEdit->clear();
|
||||
ui->extFreeTextMsgEdit->setReadOnly(false);
|
||||
update_dynamic_property(ui->extFreeTextMsgEdit, "transmitting", false);
|
||||
}
|
||||
|
||||
int MainWindow::logRxTxMessageText(QDateTime date, QString text, int freq, bool tx, int block){
|
||||
auto c = ui->textEditRX->textCursor();
|
||||
|
||||
// fixup compound callsigns cache / aliases...
|
||||
// ensure our callsign is cached...
|
||||
QString myCall = m_config.my_callsign();
|
||||
QString baseCall = Radio::base_callsign(myCall);
|
||||
if(myCall != baseCall && !m_compoundCallCache.contains(baseCall)){
|
||||
m_compoundCallCache[baseCall] = myCall;
|
||||
}
|
||||
// then, replace the cached calls that we see...
|
||||
foreach(auto call, m_compoundCallCache.keys()){
|
||||
//QRegExp re(QString("").arg(call));
|
||||
//text = text.replace(call, m_compoundCallCache[call]);
|
||||
QRegularExpression re(QString(R"((?<![\/])%1(?![\/]))").arg(QRegularExpression::escape(call)));
|
||||
QRegularExpression re(QString(R"((?<![\/])\b%1\b(?![\/]))").arg(QRegularExpression::escape(call)));
|
||||
text = text.replace(re, m_compoundCallCache[call]);
|
||||
}
|
||||
|
||||
@ -7096,9 +7109,8 @@ void MainWindow::buildQueryMenu(QMenu * menu){
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
auto snrAction = menu->addAction("? - What is my signal report?");
|
||||
|
||||
connect(snrAction, &QAction::triggered, this, [this](){
|
||||
auto ackAction = menu->addAction("? - Are you hearing me?");
|
||||
connect(ackAction, &QAction::triggered, this, [this](){
|
||||
|
||||
QString selectedCall = callsignSelected();
|
||||
if(selectedCall.isEmpty()){
|
||||
@ -7109,6 +7121,19 @@ void MainWindow::buildQueryMenu(QMenu * menu){
|
||||
toggleTx(true);
|
||||
});
|
||||
|
||||
auto snrAction = menu->addAction("^ - What is my signal report?");
|
||||
snrAction->setDisabled(isAllCall);
|
||||
connect(snrAction, &QAction::triggered, this, [this](){
|
||||
|
||||
QString selectedCall = callsignSelected();
|
||||
if(selectedCall.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
addMessageText(QString("%1^").arg(selectedCall), true);
|
||||
toggleTx(true);
|
||||
});
|
||||
|
||||
auto qthAction = menu->addAction("@ - What is your QTH message?");
|
||||
qthAction->setDisabled(isAllCall);
|
||||
connect(qthAction, &QAction::triggered, this, [this](){
|
||||
@ -8558,8 +8583,12 @@ void MainWindow::displayActivity(bool force){
|
||||
// construct reply
|
||||
QString reply;
|
||||
|
||||
// QUERIED SNR
|
||||
// QUERIED ACK
|
||||
if(d.cmd == "?"){
|
||||
reply = QString("%1 ACK").arg(Radio::base_callsign(d.from));
|
||||
}
|
||||
// QUERIED SNR
|
||||
else if(d.cmd == "^" && !isAllCall){
|
||||
reply = QString("%1 SNR %2").arg(Radio::base_callsign(d.from)).arg(Varicode::formatSNR(d.snr));
|
||||
}
|
||||
// QUERIED QTH
|
||||
|
17
varicode.cpp
17
varicode.cpp
@ -38,18 +38,19 @@ QMap<QString, int> directed_cmds = {
|
||||
// any changes here need to be made also in the directed regular xpression for parsing
|
||||
|
||||
// directed queries
|
||||
{"?", 0 }, // query snr
|
||||
{"?", 0 }, // query ack
|
||||
{"@", 1 }, // query qth
|
||||
{"&", 2 }, // query station message
|
||||
{"$", 3 }, // query station(s) heard
|
||||
{"|", 4 }, // relay message
|
||||
{"!", 5 }, // alert message
|
||||
{"^", 4 }, // query snr
|
||||
|
||||
// special responses
|
||||
// {"/", 10 }, // compound callsign
|
||||
{"|", 5 }, // relay message?
|
||||
{"!", 6 }, // alert message?
|
||||
|
||||
// {"/", 7 }, // unused? (can we even use stroke?)
|
||||
|
||||
// directed responses
|
||||
{" ACK", 23 }, // acknowledge
|
||||
{" ACK", 23 }, // acknowledged
|
||||
{" PWR", 24 }, // power level
|
||||
{" SNR", 25 }, // seen a station at the provided snr
|
||||
{" NO", 26 }, // negative confirm
|
||||
@ -60,11 +61,11 @@ QMap<QString, int> directed_cmds = {
|
||||
{" ", 31 }, // send freetext
|
||||
};
|
||||
|
||||
QSet<int> allowed_cmds = {0, 1, 2, 3, /*4,*/ /*5,*/ 10, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
QSet<int> allowed_cmds = {0, 1, 2, 3, 4, /*5,*/ 10, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||
|
||||
QRegularExpression directed_re("^"
|
||||
"(?<to>[A-Z0-9/]+)"
|
||||
"(?<cmd>\\s?(?:AGN[?]|RR|73|YES|NO|SNR|PWR|ACK|[?$@&|! ]))"
|
||||
"(?<cmd>\\s?(?:AGN[?]|RR|73|YES|NO|SNR|PWR|ACK|[?@&$^|! ]))"
|
||||
"(?<pwr>\\s?\\d+\\s?[KM]?W)?"
|
||||
"(?<num>\\s?[-+]?(?:3[01]|[0-2]?[0-9]))?"
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user