mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
* added namespace * removed some *.pri files and added files to blackcore.pro * added copyright etc.
95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
/* Copyright (C) 2019
|
|
* swift Project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
|
|
* or distributed except according to the terms contained in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef BLACKSAMPLE_MODELS_ATCSTATIONMODEL_H
|
|
#define BLACKSAMPLE_MODELS_ATCSTATIONMODEL_H
|
|
|
|
#include "dto.h"
|
|
#include <QtGlobal>
|
|
#include <QAbstractListModel>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QObject>
|
|
|
|
//! Sample ATC station
|
|
class CSampleAtcStation
|
|
{
|
|
public:
|
|
//! Ctor
|
|
CSampleAtcStation() {}
|
|
|
|
//! Ctor
|
|
CSampleAtcStation(const QString &callsign, const BlackCore::Afv::TransceiverDto &transceiver);
|
|
|
|
//! Getter @{
|
|
const QString &callsign() const { return m_callsign; }
|
|
QString formattedFrequency() const;
|
|
double latitude() const;
|
|
double longitude() const;
|
|
double radioDistanceM() const;
|
|
quint32 frequency() const;
|
|
//! @}
|
|
|
|
private:
|
|
QString m_callsign;
|
|
BlackCore::Afv::TransceiverDto m_transceiver;
|
|
};
|
|
|
|
inline bool operator==(const CSampleAtcStation &lhs, const CSampleAtcStation &rhs)
|
|
{
|
|
return lhs.callsign() == rhs.callsign() &&
|
|
qFuzzyCompare(lhs.latitude(), rhs.latitude()) &&
|
|
qFuzzyCompare(lhs.longitude(), rhs.longitude());
|
|
}
|
|
|
|
//! Sample list model
|
|
class CSampleAtcStationModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
//! Roles for model
|
|
enum AtcStationRoles
|
|
{
|
|
CallsignRole = Qt::UserRole + 1,
|
|
LatitudeRole,
|
|
LongitudeRole,
|
|
RadioDistanceRole,
|
|
FrequencyRole,
|
|
FrequencyKhzRole
|
|
};
|
|
|
|
//! Ctor
|
|
CSampleAtcStationModel(QObject *parent = nullptr);
|
|
|
|
//! Dtor
|
|
virtual ~CSampleAtcStationModel() override;
|
|
|
|
//! Update the stations
|
|
void updateAtcStations(const QVector<CSampleAtcStation> &atcStations);
|
|
|
|
//! copydoc QAbstractListModel::rowCount
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
//! copydoc QAbstractListModel::data
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
protected:
|
|
//! copydoc QAbstractListModel::roleNames
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
private:
|
|
void addStation(const CSampleAtcStation &atcStation);
|
|
void removeStationAtPosition(int i);
|
|
|
|
QList<CSampleAtcStation> m_atcStations;
|
|
};
|
|
|
|
#endif // guard
|