libdrmconf 0.14.1
A library to program DMR radios.
Loading...
Searching...
No Matches
transponderdatabase.hh
1#ifndef TRANSPONDERDATABASE_HH
2#define TRANSPONDERDATABASE_HH
3
4#include <QAbstractTableModel>
5#include <QNetworkAccessManager>
6
7#include "frequency.hh"
8
9
12{
13
14public:
16 enum class Type {
19 };
20
22 enum class Mode {
27 };
28
29public:
32
35 bool isValid() const;
36
38 unsigned int satellite() const;
40 Type type() const;
42 Mode mode() const;
43
45 const QString &name() const;
46
49 const Frequency &uplink() const;
51 const Frequency &downlink() const;
52
53public:
55 static Transponder fromSATNOGS(const QJsonObject &obj);
56
57protected:
59 unsigned int _satellite;
65 QString _name;
70};
71
72
73
76class TransponderDatabase : public QAbstractTableModel
77{
78 Q_OBJECT
79
80public:
82 typedef QVector<Transponder>::const_iterator const_iterator;
83
84public:
90 explicit TransponderDatabase(bool autoLoad, unsigned int updatePeriod = 7, QObject *parent = nullptr);
91
93 unsigned int dbAge() const;
94
96 const Transponder &getAt(unsigned int idx) const;
97
100 int rowCount(const QModelIndex &parent) const;
102 int columnCount(const QModelIndex &parent) const;
104 QVariant data(const QModelIndex &index, int role) const;
105
107 const_iterator begin() const;
109 const_iterator end() const;
110
111public slots:
113 void load();
114
115signals:
117 void loaded();
119 void error(const QString &msg);
120
121public slots:
123 void download();
124
125private slots:
127 void downloadFinished(QNetworkReply *reply);
128
129protected:
131 bool load(const QString &filename);
132
133private:
135 unsigned int _updatePeriod;
137 QVector<Transponder> _transponders;
139 QNetworkAccessManager _network;
140
141};
142
143#endif // TRANSPONDERDATABASE_HH
const Transponder & getAt(unsigned int idx) const
Returns the i-th transponder.
Definition transponderdatabase.cc:125
QVector< Transponder >::const_iterator const_iterator
Just a const iterator over all transponder.
Definition transponderdatabase.hh:82
unsigned int dbAge() const
The current age of the cache.
Definition transponderdatabase.cc:184
void error(const QString &msg)
Gets emitted if the loading one of the sources fails.
const_iterator begin() const
Returns an iterator, pointing at the first transponder.
Definition transponderdatabase.cc:173
int columnCount(const QModelIndex &parent) const
Implements the QAbstractTableModel interface.
Definition transponderdatabase.cc:136
void download()
Starts the download of the transponder.
Definition transponderdatabase.cc:255
void loaded()
Gets emitted once the transponder has been loaded.
TransponderDatabase(bool autoLoad, unsigned int updatePeriod=7, QObject *parent=nullptr)
Constructor.
Definition transponderdatabase.cc:115
const_iterator end() const
Returns an iterator, pointing right after the last transponder.
Definition transponderdatabase.cc:178
void load()
Downloads and loads all transponder information.
Definition transponderdatabase.cc:194
int rowCount(const QModelIndex &parent) const
Implements the QAbstractTableModel interface.
Definition transponderdatabase.cc:130
QVariant data(const QModelIndex &index, int role) const
Implements the QAbstractTableModel interface.
Definition transponderdatabase.cc:142
Helper type to encode frequencies without any rounding error.
Definition frequency.hh:107
Represents a single transponder of a satellite.
Definition transponderdatabase.hh:12
Mode mode() const
Returns the transponder mode.
Definition transponderdatabase.cc:41
Mode
Possible transponder modes.
Definition transponderdatabase.hh:22
@ APRS
AFSK APRS.
Definition transponderdatabase.hh:25
@ CW
Simple CW.
Definition transponderdatabase.hh:24
@ BPSK
BPSK.
Definition transponderdatabase.hh:26
@ FM
Plain FM.
Definition transponderdatabase.hh:23
Type _type
Holds the transponder type.
Definition transponderdatabase.hh:61
const Frequency & uplink() const
Returns the uplink frequency, if there is one.
Definition transponderdatabase.cc:51
bool isValid() const
Returns true, if the transponder is valid.
Definition transponderdatabase.cc:31
Frequency _downlink
Holds the downlink frequency.
Definition transponderdatabase.hh:67
static Transponder fromSATNOGS(const QJsonObject &obj)
Parses a transponder from the given SatNOGS JSON object.
Definition transponderdatabase.cc:62
Frequency _uplink
Holds the uplink frequency.
Definition transponderdatabase.hh:69
Type
Possible transponder types.
Definition transponderdatabase.hh:16
@ Transmitter
Just a transmitter (beacon).
Definition transponderdatabase.hh:18
const Frequency & downlink() const
Returns the downlink frequency.
Definition transponderdatabase.cc:56
const QString & name() const
Returns a descriptive name of the transponder.
Definition transponderdatabase.cc:46
Type type() const
Returns the transponder type.
Definition transponderdatabase.cc:36
Mode _mode
Holds the transponder mode.
Definition transponderdatabase.hh:63
Transponder()
Default constructor.
Definition transponderdatabase.cc:19
QString _name
Holds the name.
Definition transponderdatabase.hh:65
unsigned int _satellite
Holds the NORAD id of the satellite.
Definition transponderdatabase.hh:59
unsigned int satellite() const
Returns the NORAD id of the associated satellite.
Definition transponderdatabase.cc:26