QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
NTRIPSourceTable.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4
5#include <QtCore/QByteArrayView>
6#include <QtCore/QList>
7#include <QtCore/QRangeModel>
8#include <QtCore/QSortFilterProxyModel>
9#include <QtCore/QString>
10#include <QtCore/qnumeric.h>
11#include <QtPositioning/QGeoCoordinate>
12
15[[nodiscard]] bool ntripSourceTableComplete(QByteArrayView body, qsizetype checkedSize = 0);
16
21{
22 Q_GADGET
23 Q_PROPERTY(QString mountpoint MEMBER mountpoint FINAL)
24 Q_PROPERTY(QString format MEMBER format FINAL)
25 Q_PROPERTY(QString navSystem MEMBER navSystem FINAL)
26 Q_PROPERTY(QString country MEMBER country FINAL)
27 Q_PROPERTY(int bitrate MEMBER bitrate FINAL)
28 Q_PROPERTY(double distanceKm MEMBER distanceKm FINAL)
30 Q_PROPERTY(QString details READ details FINAL)
31
32public:
33 QString mountpoint;
34 QString format;
35 QString navSystem;
36 QString country;
37 int bitrate = 0;
38 double distanceKm = -1.0;
39 double latitude = qQNaN();
40 double longitude = qQNaN();
41
43 static std::optional<NTRIPMountpoint> fromSourceTableLine(const QString& line);
44
46 void updateDistance(const QGeoCoordinate& from);
47
48 QString details() const;
49};
50
51template <>
52struct QRangeModel::RowOptions<NTRIPMountpoint>
53{
54 static constexpr auto rowCategory = QRangeModel::RowCategory::MultiRoleItem;
55};
56
59class NTRIPSourceTableModel : public QRangeModel
60{
61 Q_OBJECT
62 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
63
64public:
76
77 explicit NTRIPSourceTableModel(QObject* parent = nullptr);
78
79 int count() const { return static_cast<int>(_mountpoints.size()); }
80
82 void parseSourceTable(const QString& raw, const QGeoCoordinate& from = {});
84 void updateDistances(const QGeoCoordinate& from);
85 void clear();
86
87signals:
89
90private:
91 QList<NTRIPMountpoint> _mountpoints;
92};
93
96class NTRIPSourceTableSortModel : public QSortFilterProxyModel
97{
98 Q_OBJECT
99 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
100
101public:
102 explicit NTRIPSourceTableSortModel(NTRIPSourceTableModel* source, QObject* parent = nullptr);
103
104 int count() const { return rowCount(); }
105
106signals:
108
109protected:
110 bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
111};
bool ntripSourceTableComplete(QByteArrayView body, qsizetype checkedSize=0)
Roles
Roles follow the NTRIPMountpoint property order, as QRangeModel assigns them.
void updateDistances(const QGeoCoordinate &from)
Recompute distances; one dataChanged for DistanceKmRole spans the rows whose distance changed.
void parseSourceTable(const QString &raw, const QGeoCoordinate &from={})
Publish the parsed rows and their distances in a single reset.
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
QString details() const
void updateDistance(const QGeoCoordinate &from)
Recompute distanceKm, or mark it unknown for invalid reference/mountpoint coordinates.
static std::optional< NTRIPMountpoint > fromSourceTableLine(const QString &line)
Parses one source-table line ("STR;..."); none unless it is a valid STR row.
QString mountpoint
The format, navigation systems, country, bitrate and distance that are known, as one line.