From a6a43633e84cc40abe0836982de5a630412cf43e Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 23 Jan 2023 07:20:41 +0100 Subject: [PATCH] FT8 demod: filter messages --- plugins/channelrx/demodft8/ft8demodgui.cpp | 60 ++++++++++++++++++- plugins/channelrx/demodft8/ft8demodgui.h | 6 ++ plugins/channelrx/demodft8/ft8demodgui.ui | 20 +++++++ .../demodft8/ft8demodsettingsdialog.cpp | 1 + sdrgui/resources/res.qrc | 1 + 5 files changed, 87 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/demodft8/ft8demodgui.cpp b/plugins/channelrx/demodft8/ft8demodgui.cpp index 34cdd7cf5..84af1143d 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.cpp +++ b/plugins/channelrx/demodft8/ft8demodgui.cpp @@ -219,6 +219,15 @@ void FT8DemodGUI::on_moveToBottom_clicked() ui->messages->scrollToBottom(); } +void FT8DemodGUI::on_filterMessages_toggled(bool checked) +{ + m_filterMessages = checked; + + for (int row = 0; row < ui->messages->rowCount(); row++) { + filterMessageRow(row); + } +} + void FT8DemodGUI::on_applyBandPreset_clicked() { int bandPresetIndex = ui->bandPreset->currentIndex(); @@ -358,7 +367,8 @@ FT8DemodGUI::FT8DemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban m_audioFlipChannels(false), m_audioMute(false), m_squelchOpen(false), - m_audioSampleRate(-1) + m_audioSampleRate(-1), + m_filterMessages(false) { setAttribute(Qt::WA_DeleteOnClose, true); m_helpURL = "plugins/channelrx/demodssb/readme.md"; @@ -422,6 +432,8 @@ FT8DemodGUI::FT8DemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban // Resize the table using dummy data resizeMessageTable(); populateBandPresets(); + + connect(ui->messages, &QTableWidget::cellClicked, this, &FT8DemodGUI::messageCellClicked); } FT8DemodGUI::~FT8DemodGUI() @@ -640,6 +652,7 @@ void FT8DemodGUI::makeUIConnections() QObject::connect(ui->fftWindow, QOverload::of(&QComboBox::currentIndexChanged), this, &FT8DemodGUI::on_fftWindow_currentIndexChanged); QObject::connect(ui->filterIndex, &QDial::valueChanged, this, &FT8DemodGUI::on_filterIndex_valueChanged); QObject::connect(ui->moveToBottom, &QPushButton::clicked, this, &FT8DemodGUI::on_moveToBottom_clicked); + QObject::connect(ui->filterMessages, &ButtonSwitch::toggled, this, &FT8DemodGUI::on_filterMessages_toggled); QObject::connect(ui->applyBandPreset, &QPushButton::clicked, this, &FT8DemodGUI::on_applyBandPreset_clicked); QObject::connect(ui->clearMessages, &QPushButton::clicked, this, &FT8DemodGUI::on_clearMessages_clicked); QObject::connect(ui->recordWav, &ButtonSwitch::toggled, this, &FT8DemodGUI::on_recordWav_toggled); @@ -720,6 +733,8 @@ void FT8DemodGUI::messagesReceived(const QList& messages) locItem->setText(message.loc); infoItem->setText(message.decoderInfo); + filterMessageRow(row); + row++; } @@ -741,3 +756,46 @@ void FT8DemodGUI::populateBandPresets() ui->bandPreset->blockSignals(false); } + +void FT8DemodGUI::messageCellClicked(int row, int col) +{ + m_selectedColumn = col; + m_selectedValue = ui->messages->item(row, col)->text(); + qDebug("FT8DemodGUI::messageCellChanged: %d %s", m_selectedColumn, qPrintable(m_selectedValue)); +} + +void FT8DemodGUI::filterMessageRow(int row) +{ + if (!m_filterMessages) + { + ui->messages->setRowHidden(row, false); + return; + } + + if ((m_selectedColumn == MESSAGE_COL_CALL1) || (m_selectedColumn == MESSAGE_COL_CALL2)) + { + const QString& call1 = ui->messages->item(row, MESSAGE_COL_CALL1)->text(); + const QString& call2 = ui->messages->item(row, MESSAGE_COL_CALL2)->text(); + bool visible = ((call1 == m_selectedValue) || (call2 == m_selectedValue)); + ui->messages->setRowHidden(row, !visible); + return; + } + + if (m_selectedColumn == MESSAGE_COL_LOC) + { + const QString& loc = ui->messages->item(row, MESSAGE_COL_LOC)->text(); + bool visible = (loc == m_selectedValue); + ui->messages->setRowHidden(row, !visible); + return; + } + + if (m_selectedColumn == MESSAGE_COL_UTC) + { + const QString& utc = ui->messages->item(row, MESSAGE_COL_UTC)->text(); + bool visible = (utc == m_selectedValue); + ui->messages->setRowHidden(row, !visible); + return; + } + + ui->messages->setRowHidden(row, false); +} diff --git a/plugins/channelrx/demodft8/ft8demodgui.h b/plugins/channelrx/demodft8/ft8demodgui.h index e1cc1f009..c0aeb935d 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.h +++ b/plugins/channelrx/demodft8/ft8demodgui.h @@ -81,6 +81,9 @@ private: bool m_squelchOpen; int m_audioSampleRate; uint32_t m_tickCount; + bool m_filterMessages; + int m_selectedColumn; + QString m_selectedValue; FT8Demod* m_ft8Demod; SpectrumVis* m_spectrumVis; @@ -104,6 +107,7 @@ private: void resizeMessageTable(); void messagesReceived(const QList& messages); void populateBandPresets(); + void filterMessageRow(int row); enum MessageCol { MESSAGE_COL_UTC, @@ -128,6 +132,7 @@ private slots: void on_fftWindow_currentIndexChanged(int index); void on_filterIndex_valueChanged(int value); void on_moveToBottom_clicked(); + void on_filterMessages_toggled(bool checked); void on_applyBandPreset_clicked(); void on_clearMessages_clicked(); void on_recordWav_toggled(bool checked); @@ -137,6 +142,7 @@ private slots: void onMenuDialogCalled(const QPoint& p); void handleInputMessages(); void tick(); + void messageCellClicked(int row, int col); }; #endif // INCLUDE_SSBDEMODGUI_H diff --git a/plugins/channelrx/demodft8/ft8demodgui.ui b/plugins/channelrx/demodft8/ft8demodgui.ui index b0adee3e4..6669efd17 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.ui +++ b/plugins/channelrx/demodft8/ft8demodgui.ui @@ -878,6 +878,23 @@ + + + + Filter messages + + + + + + + :/funnel.png:/funnel.png + + + true + + + @@ -893,6 +910,9 @@ 0 + + Band frequency presets + diff --git a/plugins/channelrx/demodft8/ft8demodsettingsdialog.cpp b/plugins/channelrx/demodft8/ft8demodsettingsdialog.cpp index db51c95a5..bd9e9d6c1 100644 --- a/plugins/channelrx/demodft8/ft8demodsettingsdialog.cpp +++ b/plugins/channelrx/demodft8/ft8demodsettingsdialog.cpp @@ -144,6 +144,7 @@ void FT8DemodSettingsDialog::on_addBand_clicked() ui->bands->blockSignals(true); ui->bands->setRowCount(0); populateBandsTable(); + ui->bands->scrollToBottom(); ui->bands->blockSignals(false); if (!m_settingsKeys.contains("bandPresets")) { diff --git a/sdrgui/resources/res.qrc b/sdrgui/resources/res.qrc index da1f48008..b33ebb335 100644 --- a/sdrgui/resources/res.qrc +++ b/sdrgui/resources/res.qrc @@ -1,5 +1,6 @@ + funnel.png arrow_2head_h.png truncate.png caliper.png