8#include <QNetworkAccessManager>
9#include <QAbstractTableModel>
10#include <QSortFilterProxyModel>
11#include <QGeoPositionInfoSource>
37 User(
const QJsonObject &obj);
43 unsigned distance(
unsigned id)
const;
67 explicit UserDatabase(
bool parallel,
unsigned updatePeriodDays=30, QObject *parent=
nullptr);
78 bool load(
const QString &filename);
85 void sortUsers(
const QSet<unsigned> &ids);
91 unsigned dbAge()
const;
94 int rowCount(
const QModelIndex &parent=QModelIndex())
const;
96 int columnCount(
const QModelIndex &parent=QModelIndex())
const;
98 QVariant
data(
const QModelIndex &index,
int role=Qt::DisplayRole)
const;
115 void downloadFinished(QNetworkReply *reply);
117 bool parse(QList<User> &users);
119 bool parse(
const QString &filename, QList<User> &users);
121 bool load(
const QList<User> &users);
127 QNetworkAccessManager _network;
129 QFuture<bool> _parsing;
Represents the user information within the UserDatabase.
Definition userdatabase.hh:32
QString surname
The surname of the user.
Definition userdatabase.hh:52
QString comment
Some arbitrary comment or text.
Definition userdatabase.hh:60
QString country
The country of the user.
Definition userdatabase.hh:58
unsigned distance(unsigned id) const
Returns the "distance" between this user and the given ID.
Definition userdatabase.cc:33
bool isValid() const
Returns true if the entry is valid.
Definition userdatabase.hh:40
unsigned id
The DMR ID of the user.
Definition userdatabase.hh:46
QString call
The callsign of the user.
Definition userdatabase.hh:48
QString city
The city of the user.
Definition userdatabase.hh:54
QString name
The name of the user.
Definition userdatabase.hh:50
User()
Empty constructor.
Definition userdatabase.cc:17
QString state
The state of the user.
Definition userdatabase.hh:56
qint64 count() const
Returns the number of users.
Definition userdatabase.cc:71
void readyChanged(bool ready)
Gets emitted, once the database has been loaded or cleard.
int columnCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of columns.
Definition userdatabase.cc:268
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Implements the QAbstractTableModel interface, return the entry data.
Definition userdatabase.cc:274
bool ready
Get notification, once the database has been loaded.
Definition userdatabase.hh:28
UserDatabase(bool parallel, unsigned updatePeriodDays=30, QObject *parent=nullptr)
Constructs the user-database.
Definition userdatabase.cc:52
int rowCount(const QModelIndex &parent=QModelIndex()) const
Implements the QAbstractTableModel interface, returns the number of rows (number of entries).
Definition userdatabase.cc:262
bool load()
Loads all entries from the downloaded user database.
Definition userdatabase.cc:88
unsigned dbAge() const
Returns the age of the database in days.
Definition userdatabase.cc:253
const User & user(int idx) const
Returns the user with index idx.
Definition userdatabase.cc:94
void loaded()
Gets emitted once the call-sign database has been loaded.
bool exists() const
Retruns true, if the user database file exists.
Definition userdatabase.cc:76
void sortUsers(unsigned id)
Sorts users with respect to the distance to the given ID.
Definition userdatabase.cc:187
void download()
Starts the download of the user database.
Definition userdatabase.cc:213
void error(const QString &msg)
Gets emitted if the loading of the call-sign database fails.