mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
[AFV] style, const, formatting
This commit is contained in:
@@ -38,24 +38,24 @@ namespace BlackCore
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isObject())
|
||||
{
|
||||
QJsonObject rootObject = jsonDoc.object();
|
||||
const QJsonObject rootObject = jsonDoc.object();
|
||||
QVector<CSampleAtcStation> transceivers;
|
||||
|
||||
if (rootObject.contains("controllers"))
|
||||
{
|
||||
QJsonObject otherObject = rootObject.value("controllers").toObject();
|
||||
const QJsonObject otherObject = rootObject.value("controllers").toObject();
|
||||
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
||||
{
|
||||
QString callsign = it.key();
|
||||
const QString callsign = it.key();
|
||||
if (it.value().isObject())
|
||||
{
|
||||
QJsonObject stationObject = it.value().toObject();
|
||||
const QJsonObject stationObject = it.value().toObject();
|
||||
if (stationObject.contains("transceivers"))
|
||||
{
|
||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
||||
{
|
||||
TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
transceivers.push_back({ callsign, transceiver});
|
||||
}
|
||||
}
|
||||
@@ -65,19 +65,19 @@ namespace BlackCore
|
||||
|
||||
if (rootObject.contains("other") && rootObject.value("other").isObject())
|
||||
{
|
||||
QJsonObject otherObject = rootObject.value("other").toObject();
|
||||
const QJsonObject otherObject = rootObject.value("other").toObject();
|
||||
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
||||
{
|
||||
QString callsign = it.key();
|
||||
const QString callsign = it.key();
|
||||
if (it.value().isObject())
|
||||
{
|
||||
QJsonObject stationObject = it.value().toObject();
|
||||
if (stationObject.contains("transceivers"))
|
||||
{
|
||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||
const QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
||||
{
|
||||
TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
transceivers.push_back({ callsign, transceiver});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,13 @@ namespace BlackCore
|
||||
//! Ctor
|
||||
CAfvMapReader(QObject *parent = nullptr);
|
||||
|
||||
//! Own callsign
|
||||
Q_INVOKABLE void setOwnCallsign(const QString &callsign) { m_callsign = callsign; }
|
||||
|
||||
//! Update ATC stations in model
|
||||
void updateFromMap();
|
||||
|
||||
//! ATC model
|
||||
CSampleAtcStationModel *getAtcStationModel() { return m_model; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -44,9 +44,8 @@ namespace BlackCore
|
||||
|
||||
double CSampleAtcStation::radioDistanceM() const
|
||||
{
|
||||
double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
||||
const double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
||||
const double radioFactor = 4193.18014745372;
|
||||
|
||||
return radioFactor * sqrtAltM;
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ namespace BlackCore
|
||||
for (int i = m_atcStations.size() - 1; i >= 0; i--)
|
||||
{
|
||||
CSampleAtcStation &station = m_atcStations[i];
|
||||
if (! m_atcStations.contains(station))
|
||||
if (!m_atcStations.contains(station))
|
||||
{
|
||||
removeStationAtPosition(i);
|
||||
}
|
||||
@@ -113,12 +112,12 @@ namespace BlackCore
|
||||
QHash<int, QByteArray> CSampleAtcStationModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[CallsignRole] = "callsign";
|
||||
roles[LatitudeRole] = "latitude";
|
||||
roles[LongitudeRole] = "longitude";
|
||||
roles[CallsignRole] = "callsign";
|
||||
roles[LatitudeRole] = "latitude";
|
||||
roles[LongitudeRole] = "longitude";
|
||||
roles[RadioDistanceRole] = "radioDistanceM";
|
||||
roles[FrequencyRole] = "frequencyAsString";
|
||||
roles[FrequencyKhzRole] = "frequencyKhz";
|
||||
roles[FrequencyRole] = "frequencyAsString";
|
||||
roles[FrequencyKhzRole] = "frequencyKhz";
|
||||
return roles;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user