Skip to content

Commit

Permalink
TuneDX: Added Mode for better mode tunning
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Feb 23, 2024
1 parent 1f81ac2 commit 28756b8
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 27 deletions.
2 changes: 2 additions & 0 deletions core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ int main(int argc, char* argv[])
qRegisterMetaTypeStreamOperators<QSet<int>>("QSet<int>");
#endif
qRegisterMetaType<DxSpot>();
qRegisterMetaType<BandPlan::BandPlanMode>();

set_debug_level(LEVEL_PRODUCTION); // you can set more verbose rules via
// environment variable QT_LOGGING_RULES (project setting/debug)

Expand Down
2 changes: 2 additions & 0 deletions data/BandPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ class BandPlan
BandPlan();
};

Q_DECLARE_METATYPE(BandPlan::BandPlanMode);

#endif // QLOG_DATA_BANDPLAN_H
10 changes: 9 additions & 1 deletion models/AlertTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{

}
2 changes: 2 additions & 0 deletions models/AlertTableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,6 +32,7 @@ class AlertTableModel : public QAbstractTableModel
double freq;
QString band;
QString mode;
BandPlan::BandPlanMode bandPlanMode;
QString comment;
long long counter;
DxccStatus status;
Expand Down
8 changes: 3 additions & 5 deletions ui/AlertWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ui/AlertWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public slots:

signals:
void alertsCleared();
void tuneDx(QString, double);
void tuneDx(QString, double, BandPlan::BandPlanMode);

private:
Ui::AlertWidget *ui;
Expand Down
11 changes: 7 additions & 4 deletions ui/BandmapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void BandmapWidget::updateStations()
QGraphicsItem::ItemIsSelectable |
text->flags());
text->setProperty("freq", lower.key());
text->setProperty("bandmode", static_cast<int>(lower.value().bandPlanMode));
text->setToolTip(lower.value().comment);

min_y = text_y + text->boundingRect().height() / 2;
Expand Down Expand Up @@ -639,19 +640,20 @@ 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*/
if ( lastTunedDX.callsign == call
&& lastTunedDX.freq == freq )
return;

emit tuneDx(call, freq);
emit tuneDx(call, freq, mode);
lastTunedDX.callsign = call;
lastTunedDX.freq = freq;
}
Expand Down Expand Up @@ -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<BandPlan::BandPlanMode>(focusedSpot->property("bandmode").toInt()));

}
evt->accept();
Expand Down
6 changes: 3 additions & 3 deletions ui/BandmapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down
27 changes: 22 additions & 5 deletions ui/DxWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <QDebug>
#include <QDebug>
#include <QColor>
#include <QSettings>
#include <QMessageBox>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion ui/DxWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
20 changes: 15 additions & 5 deletions ui/NewContactWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)<<callsign<< " " << frequency;
qCDebug(function_parameters) << callsign<< frequency << bandPlanMode;

if ( isManualEnterMode )
{
Expand All @@ -2441,8 +2443,16 @@ void NewContactWidget::tuneDx(const QString &callsign, double frequency)
if ( frequency > 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
Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion ui/NewContactWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "core/LogLocale.h"
#include "models/LogbookModel.h"
#include "ui/EditLine.h"
#include "data/BandPlan.h"

namespace Ui {
class NewContactWidget;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 28756b8

Please sign in to comment.