1 #ifndef TALKGROUPDATABASE_HH
2 #define TALKGROUPDATABASE_HH
4 #include <QAbstractTableModel>
5 #include <QNetworkAccessManager>
20 TalkGroup(
const QString &name,
unsigned number);
36 unsigned dbAge()
const;
44 bool load(
const QString &filename);
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;
65 void downloadFinished(QNetworkReply *reply);
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