Proper SNR formatting +00 +30 -09

This commit is contained in:
Jordan Sherer 2018-07-20 11:40:55 -04:00
parent 83c742f7ec
commit 9a945c156d
3 changed files with 15 additions and 15 deletions

View File

@ -214,13 +214,6 @@ namespace
return QString {};
}
QString formatSNR(int snr){
if(snr < -60 || snr > 60){
return QString();
}
return QString("%1%2").arg(snr >= 0 ? "+" : "").arg(snr);
}
void clearTableWidget(QTableWidget *widget){
if(!widget){
return;
@ -6857,16 +6850,14 @@ void MainWindow::on_snrMacroButton_clicked(){
if(!items.isEmpty()){
QString selectedCall = items.first()->text();
int snr = m_callActivity[selectedCall].snr;
QString text = QString("%1").arg(formatSNR(snr));
addMessageText(text);
addMessageText(Varicode::formatSNR(snr));
return;
}
int offset = ui->RxFreqSpinBox->value();
if(m_bandActivity.contains(offset)){
int snr = m_bandActivity[offset].last().snr;
QString text = QString("%1").arg(snr);
addMessageText(text);
addMessageText(Varicode::formatSNR(snr));
return;
}
}
@ -8137,7 +8128,7 @@ void MainWindow::displayActivity(bool force){
auto offsetItem = new QTableWidgetItem(QString("%1").arg(offset));
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 0, offsetItem);
auto snrItem = new QTableWidgetItem(QString("%1").arg(formatSNR(snr)));
auto snrItem = new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(snr)));
snrItem->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
ui->tableWidgetRXAll->setItem(ui->tableWidgetRXAll->rowCount() - 1, 1, snrItem);
@ -8209,7 +8200,7 @@ void MainWindow::displayActivity(bool force){
ui->tableWidgetCalls->insertRow(ui->tableWidgetCalls->rowCount());
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 0, new QTableWidgetItem(call));
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 1, new QTableWidgetItem(QString("(%1)").arg(since(d.utcTimestamp))));
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 2, new QTableWidgetItem(QString("%1").arg(formatSNR(d.snr))));
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 2, new QTableWidgetItem(QString("%1").arg(Varicode::formatSNR(d.snr))));
ui->tableWidgetCalls->setItem(ui->tableWidgetCalls->rowCount() - 1, 3, new QTableWidgetItem(QString("%1").arg(d.grid)));
auto distanceItem = new QTableWidgetItem(calculateDistance(d.grid));
@ -8287,7 +8278,7 @@ void MainWindow::displayActivity(bool force){
if(d.cmd == "?"){
// standard FT8 reply
// reply = QString("%1 %2 %3").arg(d.from).arg(m_config.my_callsign()).arg(d.snr);
reply = QString("%1 %2").arg(d.from).arg(d.snr);
reply = QString("%1 %2").arg(d.from).arg(Varicode::formatSNR(d.snr));
}
// QTH
else if(d.cmd == "@" && !isAllCall){

View File

@ -120,6 +120,13 @@ QMap<QString, quint32> basecalls = {
{ "ALLCALL", nbasecall + 3 },
};
QString Varicode::formatSNR(int snr){
if(snr < -60 || snr > 60){
return QString();
}
return QString("%1%2%3").arg(snr >= 0 ? "+" : "").arg(snr <= 9 && snr >= -9 ? "0" : "").arg(snr);
}
QStringList Varicode::parseCallsigns(QString const &input){
QStringList callsigns;
QRegularExpression re(callsign_pattern2);
@ -616,7 +623,7 @@ QStringList Varicode::unpackDirectedMessage(const QString &text){
int num = (flag ? -1 : 1) * extra;
if(num != -31){
unpacked.append(QString(num > 0 ? "+%1" : "%1").arg(num));
unpacked.append(Varicode::formatSNR(num));
}
return unpacked;

View File

@ -27,6 +27,8 @@ public:
//Varicode();
static QString formatSNR(int snr);
static QStringList parseCallsigns(QString const &input);
static QStringList parseGrids(QString const &input);