1 /* -*- c++ -*- */ 2 /* 3 * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt 4 * https://gqrx.dk/ 5 * 6 * Copyright 2020 Oliver Grossmann. 7 * 8 * Gqrx is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 3, or (at your option) 11 * any later version. 12 * 13 * Gqrx is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with Gqrx; see the file COPYING. If not, write to 20 * the Free Software Foundation, Inc., 51 Franklin Street, 21 * Boston, MA 02110-1301, USA. 22 */ 23 #ifndef DXC_SPOTS_H 24 #define DXC_SPOTS_H 25 26 #include <QtGlobal> 27 #include <QObject> 28 #include <QString> 29 #include <QMap> 30 #include <QList> 31 #include <QStringList> 32 #include <QColor> 33 #include <QTime> 34 35 struct DXCSpotInfo 36 { 37 qint64 frequency; 38 QString name; 39 QTime time; 40 QColor color; 41 DXCSpotInfoDXCSpotInfo42 DXCSpotInfo() 43 { 44 this->frequency = 0; 45 this->time = QTime::currentTime(); 46 this->color = Qt::lightGray; 47 } 48 49 bool operator<(const DXCSpotInfo &other) const 50 { 51 return frequency < other.frequency; 52 } 53 54 bool operator==(const DXCSpotInfo &other) const 55 { 56 // we check only the name because frequency can change a bit 57 // not good for multi-operator with the case callsign 58 return name == other.name; 59 } 60 61 const QColor GetColor() const; 62 }; 63 64 class DXCSpots : public QObject 65 { 66 Q_OBJECT 67 public: 68 // This is a Singleton Class now because you can not send qt-signals from static functions. 69 static void create(); 70 static DXCSpots& Get(); 71 72 void add(DXCSpotInfo& info); setSpotTimeout(int i)73 void setSpotTimeout(int i) {m_DXCSpotTimeout = i * 60;} getDXCSpot(int i)74 DXCSpotInfo& getDXCSpot(int i) { return m_DXCSpotList[i]; } 75 QList<DXCSpotInfo> getDXCSpotsInRange(qint64 low, qint64 high); 76 77 private: 78 DXCSpots(); // Singleton Constructor is private. 79 QList<DXCSpotInfo> m_DXCSpotList; 80 int m_DXCSpotTimeout; 81 static DXCSpots* m_pThis; 82 83 private slots: 84 void checkSpotTimeout(void); 85 86 signals: 87 void dxcSpotsUpdated(void); 88 }; 89 90 #endif // DXC_SPOTS_H 91