From ce6b08b15ec904ed8a68cde6743254204ff5284c Mon Sep 17 00:00:00 2001 From: srcejon Date: Sun, 22 Oct 2023 10:01:29 +0100 Subject: [PATCH] Add menu to enable/disable all rows. --- .../channelrx/freqscanner/freqscannergui.cpp | 33 ++++++++++++++++++- .../channelrx/freqscanner/freqscannergui.h | 1 + plugins/channelrx/freqscanner/readme.md | 4 +++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/freqscanner/freqscannergui.cpp b/plugins/channelrx/freqscanner/freqscannergui.cpp index d1931f8f6..0710c4757 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.cpp +++ b/plugins/channelrx/freqscanner/freqscannergui.cpp @@ -784,7 +784,13 @@ void FreqScannerGUI::updateAnnotation(int row) const SpectrumAnnotationMarker* closest = nullptr; for (const auto& marker : markers) { - if ((marker.m_startFrequency <= frequency) && (frequency < marker.m_startFrequency + marker.m_bandwidth)) + qint64 start1 = marker.m_startFrequency; + qint64 stop1 = marker.m_startFrequency + marker.m_bandwidth; + qint64 start2 = frequency - m_settings.m_channelBandwidth / 2; + qint64 stop2 = frequency + m_settings.m_channelBandwidth / 2; + if ( ((start2 >= start1) && (start2 <= stop1)) + || ((stop2 >= start1) && (stop2 <= stop1)) + ) { if (marker.m_bandwidth == (unsigned)m_settings.m_channelBandwidth) { // Exact match @@ -816,6 +822,13 @@ void FreqScannerGUI::updateAnnotations() } } +void FreqScannerGUI::setAllEnabled(bool enable) +{ + for (int i = 0; i < ui->table->rowCount(); i++) { + ui->table->item(i, COL_ENABLE)->setCheckState(enable ? Qt::Checked : Qt::Unchecked); + } +} + void FreqScannerGUI::table_customContextMenuRequested(QPoint pos) { QTableWidgetItem* item = ui->table->itemAt(pos); @@ -836,6 +849,24 @@ void FreqScannerGUI::table_customContextMenuRequested(QPoint pos) }); tableContextMenu->addAction(copyAction); + tableContextMenu->addSeparator(); + + // Enable all + + QAction* enableAllAction = new QAction("Enable all", tableContextMenu); + connect(enableAllAction, &QAction::triggered, this, [this]()->void { + setAllEnabled(true); + }); + tableContextMenu->addAction(enableAllAction); + + // Disable all + + QAction* disableAllAction = new QAction("Disable all", tableContextMenu); + connect(disableAllAction, &QAction::triggered, this, [this]()->void { + setAllEnabled(false); + }); + tableContextMenu->addAction(disableAllAction); + // Remove selected rows QAction* removeAction = new QAction("Remove", tableContextMenu); diff --git a/plugins/channelrx/freqscanner/freqscannergui.h b/plugins/channelrx/freqscanner/freqscannergui.h index 34979d1bf..9e0ec56c0 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.h +++ b/plugins/channelrx/freqscanner/freqscannergui.h @@ -96,6 +96,7 @@ private: void updateAnnotation(int row); void updateAnnotations(); void updateChannelsList(const QList& channels); + void setAllEnabled(bool enable); void leaveEvent(QEvent*); void enterEvent(EnterEventType*); diff --git a/plugins/channelrx/freqscanner/readme.md b/plugins/channelrx/freqscanner/readme.md index 737c8325b..d5126484f 100644 --- a/plugins/channelrx/freqscanner/readme.md +++ b/plugins/channelrx/freqscanner/readme.md @@ -4,6 +4,8 @@ This plugin can be used to scan a range of frequencies looking for a transmission and then tune another channel (such as an AM or DSD Demod) to that frequency. +[Tutorial Video](https://www.youtube.com/watch?v=IpKP3t4Bmmg) +

Interface

The top and bottom bars of the channel window are described [here](../../../sdrgui/channel/readme.md) @@ -101,6 +103,8 @@ When an active frequency is found after a scan, the corresponding row in the tab Right clicking on a cell will display a popup menu: - Copy contents of cell to clipboard. +- Enable all rows. +- Disable all rows. - Remove selected rows. - Tune selected channel (1) to the frequency in the row clicked on.