swift
Loading...
Searching...
No Matches
atcstationmodel.h
1// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#ifndef SWIFT_CORE_AFV_MODEL_ATCSTATIONMODEL_H
5#define SWIFT_CORE_AFV_MODEL_ATCSTATIONMODEL_H
6
7#include <QAbstractListModel>
8#include <QObject>
9#include <QtGlobal>
10
11#include "core/afv/dto.h"
13
14namespace swift::core::afv::model
15{
18 {
19 public:
21 CSampleAtcStation() = default;
22
25
28 const QString &callsign() const { return m_callsign; }
29 QString formattedFrequency() const;
30 double latitude() const;
31 double longitude() const;
32 double radioDistanceM() const;
33 quint32 frequency() const;
35
36 private:
37 QString m_callsign;
38 TransceiverDto m_transceiver;
39 };
40
41 inline bool operator==(const CSampleAtcStation &lhs, const CSampleAtcStation &rhs)
42 {
43 return lhs.callsign() == rhs.callsign() && qFuzzyCompare(lhs.latitude(), rhs.latitude()) &&
44 qFuzzyCompare(lhs.longitude(), rhs.longitude());
45 }
46
49 {
51
52 public:
55 {
56 CallsignRole = Qt::UserRole + 1,
57 LatitudeRole,
58 LongitudeRole,
59 RadioDistanceRole,
60 FrequencyRole,
61 FrequencyKhzRole
62 };
63
66
68 ~CSampleAtcStationModel() override = default;
69
71 void updateAtcStations(const QVector<CSampleAtcStation> &atcStations);
72
74 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
75
77 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
78
79 protected:
81 QHash<int, QByteArray> roleNames() const override;
82
83 private:
84 void addStation(const CSampleAtcStation &atcStation);
85 void removeStationAtPosition(int i);
86
87 QList<CSampleAtcStation> m_atcStations;
88 };
89} // namespace swift::core::afv::model
90
91#endif // SWIFT_CORE_AFV_MODEL_ATCSTATIONMODEL_H
const QString & callsign() const
Getter.
void updateAtcStations(const QVector< CSampleAtcStation > &atcStations)
Update the stations.
QHash< int, QByteArray > roleNames() const
copydoc QAbstractListModel::roleNames
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
copydoc QAbstractListModel::data
CSampleAtcStationModel(QObject *parent=nullptr)
Ctor.
int rowCount(const QModelIndex &parent=QModelIndex()) const
copydoc QAbstractListModel::rowCount
virtual QModelIndex parent(const QModelIndex &index) const const=0
QAbstractListModel(QObject *parent)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
QObject * parent() const const
UserRole
#define SWIFT_CORE_EXPORT
Export a class or function from the library.