1 #ifndef USERDATABASE_HH
2 #define USERDATABASE_HH
8 #include <QNetworkAccessManager>
9 #include <QAbstractTableModel>
10 #include <QSortFilterProxyModel>
11 #include <QGeoPositionInfoSource>
33 User(
const QJsonObject &obj);
39 unsigned distance(
unsigned id)
const;
63 explicit UserDatabase(
unsigned updatePeriodDays=30, QObject *parent=
nullptr);
71 bool load(
const QString &filename);
76 void sortUsers(
const QSet<unsigned> &ids);
82 unsigned dbAge()
const;
85 int rowCount(
const QModelIndex &parent=QModelIndex())
const;
87 int columnCount(
const QModelIndex &parent=QModelIndex())
const;
89 QVariant
data(
const QModelIndex &index,
int role=Qt::DisplayRole)
const;
103 void downloadFinished(QNetworkReply *reply);
109 QNetworkAccessManager _network;
Represents the user information within the UserDatabase.
Definition: userdatabase.hh:28
QString surname
The surname of the user.
Definition: userdatabase.hh:48
QString comment
Some arbitrary comment or text.
Definition: userdatabase.hh:56
QString country
The country of the user.
Definition: userdatabase.hh:54
unsigned distance(unsigned id) const
Returns the "distance" between this user and the given ID.
Definition: userdatabase.cc:32
bool isValid() const
Returns true if the entry is valid.
Definition: userdatabase.hh:36
unsigned id
The DMR ID of the user.
Definition: userdatabase.hh:42
QString call
The callsign of the user.
Definition: userdatabase.hh:44
QString city
The city of the user.
Definition: userdatabase.hh:50
QString name
The name of the user.
Definition: userdatabase.hh:46
User()
Empty constructor.
Definition: userdatabase.cc:16
QString state
The state of the user.
Definition: userdatabase.hh:52
Auto-updating DMR user database.
Definition: userdatabase.hh:23
qint64 count() const
Returns the number of users.
Definition: userdatabase.cc:62
int columnCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of columns.
Definition: userdatabase.cc:220
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Implements the QAbstractTableModel interface, return the entry data.
Definition: userdatabase.cc:226
int rowCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of rows (number of entries).
Definition: userdatabase.cc:214
bool load()
Loads all entries from the downloaded user database.
Definition: userdatabase.cc:67
unsigned dbAge() const
Returns the age of the database in days.
Definition: userdatabase.cc:205
const User & user(int idx) const
Returns the user with index idx.
Definition: userdatabase.cc:73
void loaded()
Gets emitted once the call-sign database has been loaded.
UserDatabase(unsigned updatePeriodDays=30, QObject *parent=nullptr)
Constructs the user-database.
Definition: userdatabase.cc:51
void sortUsers(unsigned id)
Sorts users with respect to the distance to the given ID.
Definition: userdatabase.cc:139
void download()
Starts the download of the user database.
Definition: userdatabase.cc:165
void error(const QString &msg)
Gets emitted if the loading of the call-sign database fails.