libdrmconf 0.12.1
A library to program DMR radios.
Loading...
Searching...
No Matches
talkgroupdatabase.hh
1#ifndef TALKGROUPDATABASE_HH
2#define TALKGROUPDATABASE_HH
3
4#include <QAbstractTableModel>
5#include <QNetworkAccessManager>
6
10class TalkGroupDatabase : public QAbstractTableModel
11{
12 Q_OBJECT
13
15 class TalkGroup {
16 public:
18 TalkGroup();
20 TalkGroup(const QString &name, unsigned number);
22 unsigned id;
24 QString name;
25 };
26
27public:
31 TalkGroupDatabase(unsigned updatePeriodDays=30, QObject *parent=nullptr);
32
34 qint64 count() const;
36 unsigned dbAge() const;
37
39 TalkGroup talkgroup(int index) const;
40
42 bool load();
44 bool load(const QString &filename);
45
47 int rowCount(const QModelIndex &parent=QModelIndex()) const;
49 int columnCount(const QModelIndex &parent=QModelIndex()) const;
51 QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
52
53signals:
55 void loaded();
57 void error(const QString &msg);
58
59public slots:
61 void download();
62
63private slots:
65 void downloadFinished(QNetworkReply *reply);
66
67protected:
69 QVector<TalkGroup> _talkgroups;
71 QNetworkAccessManager _network;
72};
73
74#endif // TALKGROUPDATABASE_HH
Downloads, periodically updates and provides a list of talk group IDs and their names.
Definition talkgroupdatabase.hh:11
TalkGroup talkgroup(int index) const
Returns the talk group entry at the given index.
Definition talkgroupdatabase.cc:55
void download()
Starts the download of the talk group database.
Definition talkgroupdatabase.cc:62
unsigned dbAge() const
Returns the age of the database in days.
Definition talkgroupdatabase.cc:46
bool load()
Loads all entries from the downloaded talk group db.
Definition talkgroupdatabase.cc:102
int columnCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of columns.
Definition talkgroupdatabase.cc:155
qint64 count() const
Returns the number of talk groups.
Definition talkgroupdatabase.cc:41
QNetworkAccessManager _network
The network access used for downloading.
Definition talkgroupdatabase.hh:71
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Implements the QAbstractTableModel interface, return the entry data.
Definition talkgroupdatabase.cc:161
void loaded()
Gets emitted once the talk group database has been loaded.
void error(const QString &msg)
Gets emitted if the loading of the talk group database fails.
QVector< TalkGroup > _talkgroups
Holds all talk groups as id->name table.
Definition talkgroupdatabase.hh:69
TalkGroupDatabase(unsigned updatePeriodDays=30, QObject *parent=nullptr)
Constructs a talk group database.
Definition talkgroupdatabase.cc:30
int rowCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of rows (number of entries).
Definition talkgroupdatabase.cc:149