diff --git a/core/main.cpp b/core/main.cpp index 446bc328..744af28b 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -418,6 +418,8 @@ int main(int argc, char* argv[]) qRegisterMetaTypeStreamOperators>("QSet"); #endif qRegisterMetaType(); + qRegisterMetaType(); + set_debug_level(LEVEL_PRODUCTION); // you can set more verbose rules via // environment variable QT_LOGGING_RULES (project setting/debug) diff --git a/data/BandPlan.h b/data/BandPlan.h index ed945752..5fdb1737 100644 --- a/data/BandPlan.h +++ b/data/BandPlan.h @@ -38,4 +38,6 @@ class BandPlan BandPlan(); }; +Q_DECLARE_METATYPE(BandPlan::BandPlanMode); + #endif // QLOG_DATA_BANDPLAN_H diff --git a/models/AlertTableModel.cpp b/models/AlertTableModel.cpp index bf71299b..6674f6cd 100644 --- a/models/AlertTableModel.cpp +++ b/models/AlertTableModel.cpp @@ -114,6 +114,14 @@ double AlertTableModel::getFrequency(const QModelIndex &index) return ret; } +BandPlan::BandPlanMode AlertTableModel::getBandPlanMode(const QModelIndex &index) +{ + alertListMutex.lock(); + BandPlan::BandPlanMode ret = alertList.at(index.row()).bandPlanMode; + alertListMutex.unlock(); + return ret; +} + void AlertTableModel::aging(const int clear_interval_sec) { if ( clear_interval_sec <= 0 ) return; @@ -154,9 +162,9 @@ AlertTableModel::AlertTableRecord::AlertTableRecord(const SpotAlert &spotAlert) freq(spotAlert.freq), band(spotAlert.band), mode(spotAlert.modeGroupString), + bandPlanMode(spotAlert.bandPlanMode), comment(spotAlert.comment), counter(0), status(spotAlert.status) { - } diff --git a/models/AlertTableModel.h b/models/AlertTableModel.h index 2dcacd3d..7fa1a25b 100644 --- a/models/AlertTableModel.h +++ b/models/AlertTableModel.h @@ -20,6 +20,7 @@ class AlertTableModel : public QAbstractTableModel void clear(); QString getCallsign(const QModelIndex& index); double getFrequency(const QModelIndex& index); + BandPlan::BandPlanMode getBandPlanMode(const QModelIndex &index); void aging(const int clear_interval_sec); private: @@ -31,6 +32,7 @@ class AlertTableModel : public QAbstractTableModel double freq; QString band; QString mode; + BandPlan::BandPlanMode bandPlanMode; QString comment; long long counter; DxccStatus status; diff --git a/ui/AlertWidget.cpp b/ui/AlertWidget.cpp index 2d262b8c..85cbbc2c 100644 --- a/ui/AlertWidget.cpp +++ b/ui/AlertWidget.cpp @@ -65,11 +65,9 @@ void AlertWidget::clearAllAlerts() void AlertWidget::entryDoubleClicked(QModelIndex index) { FCT_IDENTIFICATION; - - - QString callsign = alertTableModel->getCallsign(index); - double frequency = alertTableModel->getFrequency(index); - emit tuneDx(callsign, frequency); + emit tuneDx(alertTableModel->getCallsign(index), + alertTableModel->getFrequency(index), + alertTableModel->getBandPlanMode(index)); } void AlertWidget::alertAgingChanged(int) diff --git a/ui/AlertWidget.h b/ui/AlertWidget.h index e190448e..2228d1d9 100644 --- a/ui/AlertWidget.h +++ b/ui/AlertWidget.h @@ -28,7 +28,7 @@ public slots: signals: void alertsCleared(); - void tuneDx(QString, double); + void tuneDx(QString, double, BandPlan::BandPlanMode); private: Ui::AlertWidget *ui; diff --git a/ui/BandmapWidget.cpp b/ui/BandmapWidget.cpp index a6cddc04..433fd1b0 100644 --- a/ui/BandmapWidget.cpp +++ b/ui/BandmapWidget.cpp @@ -224,6 +224,7 @@ void BandmapWidget::updateStations() QGraphicsItem::ItemIsSelectable | text->flags()); text->setProperty("freq", lower.key()); + text->setProperty("bandmode", static_cast(lower.value().bandPlanMode)); text->setToolTip(lower.value().comment); min_y = text_y + text->boundingRect().height() / 2; @@ -639,11 +640,12 @@ void BandmapWidget::focusZoomFreq(int, int) } void BandmapWidget::spotClicked(const QString &call, - double freq) + double freq, + BandPlan::BandPlanMode mode) { FCT_IDENTIFICATION; - qCDebug(function_parameters) << call << freq; + qCDebug(function_parameters) << call << freq << mode; qCDebug(runtime) << "Last Tuned DX" << lastTunedDX.callsign << lastTunedDX.freq; /* Do not emit the Spot two times - double click*/ @@ -651,7 +653,7 @@ void BandmapWidget::spotClicked(const QString &call, && lastTunedDX.freq == freq ) return; - emit tuneDx(call, freq); + emit tuneDx(call, freq, mode); lastTunedDX.callsign = call; lastTunedDX.freq = freq; } @@ -925,7 +927,8 @@ void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *evt) if ( focusedSpot ) { emit spotClicked(focusedSpot->toPlainText().split(" ").first(), - focusedSpot->property("freq").toDouble()); + focusedSpot->property("freq").toDouble(), + static_cast(focusedSpot->property("bandmode").toInt())); } evt->accept(); diff --git a/ui/BandmapWidget.h b/ui/BandmapWidget.h index 047b7bf5..3e50845a 100644 --- a/ui/BandmapWidget.h +++ b/ui/BandmapWidget.h @@ -29,7 +29,7 @@ class GraphicsScene : public QGraphicsScene explicit GraphicsScene(QObject *parent = nullptr) : QGraphicsScene(parent){}; signals: - void spotClicked(QString, double); + void spotClicked(QString, double, BandPlan::BandPlanMode mode); protected: void mousePressEvent (QGraphicsSceneMouseEvent *evt) override; @@ -65,7 +65,7 @@ public slots: void spotsDxccStatusRecal(const QSqlRecord &record); signals: - void tuneDx(QString, double); + void tuneDx(QString, double, BandPlan::BandPlanMode); void nearestSpotFound(const DxSpot &); private: @@ -91,7 +91,7 @@ public slots: private slots: void centerRXActionChecked(bool); - void spotClicked(const QString&, double); + void spotClicked(const QString&, double, BandPlan::BandPlanMode); void showContextMenu(const QPoint&); void updateStationTimer(); void focusZoomFreq(int, int); diff --git a/ui/DxWidget.cpp b/ui/DxWidget.cpp index 1e17204a..59d26ff8 100644 --- a/ui/DxWidget.cpp +++ b/ui/DxWidget.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -151,6 +151,11 @@ double DxTableModel::getFrequency(const QModelIndex& index) { return dxData.at(index.row()).freq; } +BandPlan::BandPlanMode DxTableModel::getBandPlanode(const QModelIndex &index) +{ + return dxData.at(index.row()).bandPlanMode; +} + void DxTableModel::clear() { beginResetModel(); dxData.clear(); @@ -1178,12 +1183,13 @@ void DxWidget::viewModeChanged(int index) ui->stack->setCurrentIndex(index); } -void DxWidget::entryDoubleClicked(QModelIndex index) { +void DxWidget::entryDoubleClicked(QModelIndex index) +{ FCT_IDENTIFICATION; - QString callsign = dxTableModel->getCallsign(index); - double frequency = dxTableModel->getFrequency(index); - emit tuneDx(callsign, frequency); + emit tuneDx(dxTableModel->getCallsign(index), + dxTableModel->getFrequency(index), + dxTableModel->getBandPlanode(index)); } void DxWidget::actionFilter() @@ -1502,6 +1508,11 @@ void DxWidget::processDxSpot(const QString &spotter, { spot.bandPlanMode = BandPlan::freq2BandMode(spot.freq); } + if ( spot.bandPlanMode == BandPlan::BAND_MODE_PHONE ) + { + spot.bandPlanMode = (spot.freq < 10.0 ) ? BandPlan::BAND_MODE_LSB + : BandPlan::BAND_MODE_USB; + } spot.modeGroupString = BandPlan::bandMode2BandModeGroupString(spot.bandPlanMode); spot.dxcc = dxcc; spot.dxcc_spotter = dxcc_spotter; @@ -1560,6 +1571,12 @@ BandPlan::BandPlanMode DxWidget::modeGroupFromComment(const QString &comment) co if ( tokenizedComment.contains("SSB", Qt::CaseInsensitive) ) return BandPlan::BAND_MODE_PHONE; + if ( tokenizedComment.contains("USB", Qt::CaseInsensitive) ) + return BandPlan::BAND_MODE_USB; + + if ( tokenizedComment.contains("LSB", Qt::CaseInsensitive) ) + return BandPlan::BAND_MODE_LSB; + return BandPlan::BAND_MODE_UNKNOWN; } diff --git a/ui/DxWidget.h b/ui/DxWidget.h index 1acd4cd7..61ba7432 100644 --- a/ui/DxWidget.h +++ b/ui/DxWidget.h @@ -39,6 +39,7 @@ class DxTableModel : public QAbstractTableModel { double freq_tolerance = DEDUPLICATION_FREQ_TOLERANCE); QString getCallsign(const QModelIndex& index); double getFrequency(const QModelIndex& index); + BandPlan::BandPlanMode getBandPlanode(const QModelIndex& index); void clear(); private: @@ -146,7 +147,7 @@ private slots: void displayedColumns(); signals: - void tuneDx(QString, double); + void tuneDx(QString, double, BandPlan::BandPlanMode); void newSpot(DxSpot); void newWCYSpot(WCYSpot); void newWWVSpot(WWVSpot); diff --git a/ui/MainWindow.cpp b/ui/MainWindow.cpp index 1947892d..cad9f387 100644 --- a/ui/MainWindow.cpp +++ b/ui/MainWindow.cpp @@ -384,7 +384,9 @@ void MainWindow::processSpotAlert(SpotAlert alert) connect(alertTextButton, &QPushButton::clicked, this, [this, alert]() { - ui->newContactWidget->tuneDx(alert.callsign, alert.freq); + ui->newContactWidget->tuneDx(alert.callsign, + alert.freq, + alert.bandPlanMode); }); if ( ui->actionBeepSettingAlert->isChecked() ) diff --git a/ui/NewContactWidget.cpp b/ui/NewContactWidget.cpp index 2bb49c58..636232ac 100644 --- a/ui/NewContactWidget.cpp +++ b/ui/NewContactWidget.cpp @@ -2426,11 +2426,13 @@ void NewContactWidget::setBandLabel(const QString &band) ui->bandRXLabel->setText(band); } -void NewContactWidget::tuneDx(const QString &callsign, double frequency) +void NewContactWidget::tuneDx(const QString &callsign, + double frequency, + const BandPlan::BandPlanMode bandPlanMode) { FCT_IDENTIFICATION; - qCDebug(function_parameters)< 0.0 ) { QString subMode; - const QString &mode = BandPlan::freq2ExpectedMode(frequency, - subMode); + QString mode = BandPlan::bandPlanMode2ExpectedMode(bandPlanMode, + subMode); + + if ( mode.isEmpty() ) + { + qCDebug(runtime) << "mode not found" << bandPlanMode; + mode = BandPlan::freq2ExpectedMode(frequency, + subMode); + } + if ( !mode.isEmpty() ) { // in case of SSB, do not sent 2 mode changes to rig @@ -2476,7 +2486,7 @@ void NewContactWidget::fillCallsignGrid(const QString &callsign, const QString & { FCT_IDENTIFICATION; qCDebug(function_parameters) << callsign<< grid; - tuneDx(callsign, -1); + tuneDx(callsign, -1, BandPlan::BAND_MODE_UNKNOWN); uiDynamic->gridEdit->setText(grid); } diff --git a/ui/NewContactWidget.h b/ui/NewContactWidget.h index a1b9c5e6..ce598edf 100644 --- a/ui/NewContactWidget.h +++ b/ui/NewContactWidget.h @@ -21,6 +21,7 @@ #include "core/LogLocale.h" #include "models/LogbookModel.h" #include "ui/EditLine.h" +#include "data/BandPlan.h" namespace Ui { class NewContactWidget; @@ -183,7 +184,9 @@ public slots: void refreshRigProfileCombo(); void saveExternalContact(QSqlRecord record); void readGlobalSettings(); - void tuneDx(const QString &callsign, double frequency); + void tuneDx(const QString &callsign, + double frequency, + const BandPlan::BandPlanMode mode); void fillCallsignGrid(const QString &callsign, const QString& grid); void showDx(const QString &callsign, const QString &grid); void resetContact();