Skip to content

Commit

Permalink
Revert "Use single-shot timer to remove old spots"
Browse files Browse the repository at this point in the history
This reverts commit 967ccca.
  • Loading branch information
Vladisslav P committed Oct 4, 2023
1 parent e89c8cf commit 986b26f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
15 changes: 13 additions & 2 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent)

// create DXC Objects
dxc_options = new DXCOptions(this);
dxc_timer = new QTimer(this);
dxc_timer->start(1000);

/* create dock widgets */
uiDockRxOpt = new DockRxOpt();
Expand Down Expand Up @@ -314,7 +316,8 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent)
connect(&Bookmarks::Get(), SIGNAL(BookmarksChanged()), ui->plotter, SLOT(updateOverlay()));

//DXC Spots
connect(&DXCSpots::Get(), SIGNAL(dxcSpotsUpdated()), this, SLOT(updateClusterSpots()));
connect(&DXCSpots::Get(), SIGNAL(dxcSpotsChanged()),this , SLOT(addClusterSpot()));
connect(dxc_timer, SIGNAL(timeout()), this, SLOT(checkDXCSpotTimeout()));

// I/Q playback
connect(iq_tool, SIGNAL(startRecording(QString)), this, SLOT(startIqRecording(QString)));
Expand Down Expand Up @@ -407,6 +410,9 @@ MainWindow::~MainWindow()
audio_fft_timer->stop();
delete audio_fft_timer;

dxc_timer->stop();
delete dxc_timer;

if (m_settings)
{
m_settings->setValue("configversion", 4);
Expand Down Expand Up @@ -2491,7 +2497,7 @@ void MainWindow::on_actionAddBookmark_triggered()
}
}

void MainWindow::updateClusterSpots()
void MainWindow::addClusterSpot()
{
ui->plotter->updateOverlay();
}
Expand All @@ -2517,3 +2523,8 @@ void MainWindow::toggleMarkers()
enableMarkers(!d_show_markers);
uiDockFft->setMarkersEnabled(d_show_markers);
}

void MainWindow::checkDXCSpotTimeout()
{
DXCSpots::Get().checkSpotTimeout();
}
4 changes: 3 additions & 1 deletion src/applications/gqrx/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public slots:
quint64 d_last_fft_ms;
float d_avg_fft_rate;
bool d_frame_drop;
QTimer *dxc_timer;

receiver *rx;

Expand Down Expand Up @@ -224,7 +225,7 @@ private slots:
void onBookmarkActivated(qint64 freq, const QString& demod, int bandwidth);

/* DXC Spots */
void updateClusterSpots();
void addClusterSpot();

/* menu and toolbar actions */
void on_actionDSP_triggered(bool checked);
Expand Down Expand Up @@ -261,6 +262,7 @@ private slots:
void iqFftTimeout();
void audioFftTimeout();
void rdsTimeout();
void checkDXCSpotTimeout();
};

#endif // MAINWINDOW_H
6 changes: 2 additions & 4 deletions src/qtgui/dxc_spots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <QTextStream>
#include <QString>
#include <QSet>
#include <QTimer>
#include <algorithm>
#include "dxc_spots.h"
#include <stdio.h>
Expand Down Expand Up @@ -57,8 +56,7 @@ void DXCSpots::add(DXCSpotInfo &info)
m_DXCSpotList.removeAt(m_DXCSpotList.indexOf(info));
m_DXCSpotList.append(info);
std::stable_sort(m_DXCSpotList.begin(),m_DXCSpotList.end());
emit( dxcSpotsUpdated() );
QTimer::singleShot(m_DXCSpotTimeout, this, SLOT(checkSpotTimeout()));
emit( dxcSpotsChanged() );
}

void DXCSpots::checkSpotTimeout()
Expand All @@ -73,7 +71,7 @@ void DXCSpots::checkSpotTimeout()
}
}
std::stable_sort(m_DXCSpotList.begin(),m_DXCSpotList.end());
emit( dxcSpotsUpdated() );
emit( dxcSpotsChanged() );
}

QList<DXCSpotInfo> DXCSpots::getDXCSpotsInRange(qint64 low, qint64 high)
Expand Down
6 changes: 2 additions & 4 deletions src/qtgui/dxc_spots.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class DXCSpots : public QObject

void add(DXCSpotInfo& info);
void setSpotTimeout(int i) { m_DXCSpotTimeout = std::chrono::seconds(i * 60); }
void checkSpotTimeout();
DXCSpotInfo& getDXCSpot(int i) { return m_DXCSpotList[i]; }
QList<DXCSpotInfo> getDXCSpotsInRange(qint64 low, qint64 high);

Expand All @@ -80,11 +81,8 @@ class DXCSpots : public QObject
std::chrono::seconds m_DXCSpotTimeout;
static DXCSpots* m_pThis;

private slots:
void checkSpotTimeout(void);

signals:
void dxcSpotsUpdated(void);
void dxcSpotsChanged(void);
};

#endif // DXC_SPOTS_H

0 comments on commit 986b26f

Please sign in to comment.