mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #395, added isInRange to ATC stations
* use null as default values for some members to detect those are not yet set * used simplified bool formatter for views
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a3b147d59a
commit
3300b1ad9b
@@ -55,6 +55,7 @@ namespace BlackGui
|
|||||||
col.setSortPropertyIndex({ CAtcStation::IndexCallsign, CCallsign::IndexSuffix });
|
col.setSortPropertyIndex({ CAtcStation::IndexCallsign, CCallsign::IndexSuffix });
|
||||||
this->m_columns.addColumn(col);
|
this->m_columns.addColumn(col);
|
||||||
this->m_columns.addColumn(CColumn("distance", CAtcStation::IndexDistanceToOwnAircraft, new CAirspaceDistanceFormatter()));
|
this->m_columns.addColumn(CColumn("distance", CAtcStation::IndexDistanceToOwnAircraft, new CAirspaceDistanceFormatter()));
|
||||||
|
this->m_columns.addColumn(CColumn("r.", "in range", CAtcStation::IndexIsInRange, new CBoolIconFormatter("in range", "outside range")));
|
||||||
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
|
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
|
||||||
this->m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
|
this->m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
|
||||||
this->m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
|
this->m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace BlackGui
|
|||||||
this->m_columns.addColumn(CColumn::standardString("capabilities", CClient::IndexCapabilitiesString));
|
this->m_columns.addColumn(CColumn::standardString("capabilities", CClient::IndexCapabilitiesString));
|
||||||
this->m_columns.addColumn(CColumn::standardString("model", {CClient::IndexModel, CAircraftModel::IndexModelString}));
|
this->m_columns.addColumn(CColumn::standardString("model", {CClient::IndexModel, CAircraftModel::IndexModelString}));
|
||||||
this->m_columns.addColumn(CColumn("q.?", "queried", {CClient::IndexModel, CAircraftModel::IndexHasQueriedModelString},
|
this->m_columns.addColumn(CColumn("q.?", "queried", {CClient::IndexModel, CAircraftModel::IndexHasQueriedModelString},
|
||||||
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "queried", "not queried")));
|
new CBoolIconFormatter("queried", "not queried")));
|
||||||
this->m_columns.addColumn(CColumn::standardString("server", CClient::IndexServer));
|
this->m_columns.addColumn(CColumn::standardString("server", CClient::IndexServer));
|
||||||
|
|
||||||
// force strings for translation in resource files
|
// force strings for translation in resource files
|
||||||
|
|||||||
@@ -316,7 +316,11 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBoolIconFormatter::CBoolIconFormatter(int alignment) :
|
CBoolIconFormatter::CBoolIconFormatter(int alignment) :
|
||||||
CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconEmpty16, "on", "off", alignment)
|
CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "on", "off", alignment)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CBoolIconFormatter::CBoolIconFormatter(const QString &onName, const QString &offName, int alignment) :
|
||||||
|
CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, onName, offName, alignment)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
CBoolIconFormatter::CBoolIconFormatter(CIcons::IconIndex onIcon, CIcons::IconIndex offIcon, const QString &onName, const QString &offName, int alignment) :
|
CBoolIconFormatter::CBoolIconFormatter(CIcons::IconIndex onIcon, CIcons::IconIndex offIcon, const QString &onName, const QString &offName, int alignment) :
|
||||||
|
|||||||
@@ -205,6 +205,9 @@ namespace BlackGui
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
CBoolIconFormatter(int alignment = alignDefault());
|
CBoolIconFormatter(int alignment = alignDefault());
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
CBoolIconFormatter(const QString &onName, const QString &offName, int alignment = alignDefault());
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CBoolIconFormatter(const BlackMisc::CIcon &onIcon, const BlackMisc::CIcon &offIcon, const QString &onName, const QString &offName, int alignment = alignDefault());
|
CBoolIconFormatter(const BlackMisc::CIcon &onIcon, const BlackMisc::CIcon &offIcon, const QString &onName, const QString &offName, int alignment = alignDefault());
|
||||||
|
|
||||||
|
|||||||
@@ -69,16 +69,16 @@ namespace BlackGui
|
|||||||
|
|
||||||
case ModelMode:
|
case ModelMode:
|
||||||
this->m_columns.addColumn(CColumn("e.", "enabled", CSimulatedAircraft::IndexEnabled,
|
this->m_columns.addColumn(CColumn("e.", "enabled", CSimulatedAircraft::IndexEnabled,
|
||||||
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "enabled", "disabled"), true));
|
new CBoolIconFormatter("enabled", "disabled"), true));
|
||||||
this->m_columns.addColumn(CColumn("r.", "rendered", CSimulatedAircraft::IndexRendered,
|
this->m_columns.addColumn(CColumn("r.", "rendered", CSimulatedAircraft::IndexRendered,
|
||||||
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "rendered", "skipped"), true));
|
new CBoolIconFormatter("rendered", "skipped"), true));
|
||||||
this->m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", { CSimulatedAircraft::IndexCallsign, CCallsign::IndexCallsignString }));
|
this->m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", { CSimulatedAircraft::IndexCallsign, CCallsign::IndexCallsignString }));
|
||||||
this->m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CSimulatedAircraft::IndexPilot, CUser::IndexRealName }));
|
this->m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CSimulatedAircraft::IndexPilot, CUser::IndexRealName }));
|
||||||
this->m_columns.addColumn(CColumn("dist.", "distance", CSimulatedAircraft::IndexDistanceToOwnAircraft, new CAirspaceDistanceFormatter()));
|
this->m_columns.addColumn(CColumn("dist.", "distance", CSimulatedAircraft::IndexDistanceToOwnAircraft, new CAirspaceDistanceFormatter()));
|
||||||
this->m_columns.addColumn(CColumn("p.", "parts", CSimulatedAircraft::IndexPartsSynchronized,
|
this->m_columns.addColumn(CColumn("p.", "parts", CSimulatedAircraft::IndexPartsSynchronized,
|
||||||
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "parts", "no parts"), true));
|
new CBoolIconFormatter("parts", "no parts"), true));
|
||||||
this->m_columns.addColumn(CColumn("fp.", "fast position updates", CSimulatedAircraft::IndexFastPositionUpdates,
|
this->m_columns.addColumn(CColumn("fp.", "fast position updates", CSimulatedAircraft::IndexFastPositionUpdates,
|
||||||
new CBoolIconFormatter(CIcons::StandardIconTick16, CIcons::StandardIconCross16, "enabled", "disabled"), true));
|
new CBoolIconFormatter("enabled", "disabled"), true));
|
||||||
this->m_columns.addColumn(CColumn::standardString("icao", { CSimulatedAircraft::IndexIcao, CAircraftIcao::IndexAsString}));
|
this->m_columns.addColumn(CColumn::standardString("icao", { CSimulatedAircraft::IndexIcao, CAircraftIcao::IndexAsString}));
|
||||||
this->m_columns.addColumn(CColumn::standardString("model", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelString}));
|
this->m_columns.addColumn(CColumn::standardString("model", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelString}));
|
||||||
this->m_columns.addColumn(CColumn::standardString("desc.", "description", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexDescription}));
|
this->m_columns.addColumn(CColumn::standardString("desc.", "description", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexDescription}));
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAtcStation::hasBookingTimes() const
|
||||||
|
{
|
||||||
|
return !(this->m_bookedFromUtc.isNull() && this->m_bookedUntilUtc.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
bool CAtcStation::hasMetar() const
|
bool CAtcStation::hasMetar() const
|
||||||
{
|
{
|
||||||
return this->m_metar.hasMessage();
|
return this->m_metar.hasMessage();
|
||||||
@@ -181,6 +186,24 @@ namespace BlackMisc
|
|||||||
otherStation.setController(otherController);
|
otherStation.setController(otherController);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAtcStation::isInRange() const
|
||||||
|
{
|
||||||
|
if (m_range.isNull() || !hasValidDistance()) { return false; }
|
||||||
|
return (this->getDistanceToOwnAircraft() <= m_range);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CAtcStation::hasValidBookingTimes() const
|
||||||
|
{
|
||||||
|
return !this->m_bookedFromUtc.isNull() && this->m_bookedFromUtc.isValid() &&
|
||||||
|
!this->m_bookedUntilUtc.isNull() && this->m_bookedUntilUtc.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAtcStation::setBookedFromUntil(const CAtcStation &otherStation)
|
||||||
|
{
|
||||||
|
this->setBookedFromUtc(otherStation.getBookedFromUtc());
|
||||||
|
this->setBookedUntilUtc(otherStation.getBookedUntilUtc());
|
||||||
|
}
|
||||||
|
|
||||||
bool CAtcStation::isBookedNow() const
|
bool CAtcStation::isBookedNow() const
|
||||||
{
|
{
|
||||||
if (!this->hasValidBookingTimes()) return false;
|
if (!this->hasValidBookingTimes()) return false;
|
||||||
@@ -190,9 +213,14 @@ namespace BlackMisc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAtcStation::isComUnitTunedIn25KHz(const CComSystem &comUnit) const
|
||||||
|
{
|
||||||
|
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
||||||
|
}
|
||||||
|
|
||||||
CTime CAtcStation::bookedWhen() const
|
CTime CAtcStation::bookedWhen() const
|
||||||
{
|
{
|
||||||
if (!this->hasValidBookingTimes()) return CTime(-365.0, CTimeUnit::d());
|
if (!this->hasValidBookingTimes()) { return CTime(0, CTimeUnit::nullUnit()); }
|
||||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||||
qint64 diffMs;
|
qint64 diffMs;
|
||||||
if (this->m_bookedFromUtc > now)
|
if (this->m_bookedFromUtc > now)
|
||||||
@@ -257,6 +285,8 @@ namespace BlackMisc
|
|||||||
return this->m_position.propertyByIndex(index.copyFrontRemoved());
|
return this->m_position.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexRange:
|
case IndexRange:
|
||||||
return this->m_range.propertyByIndex(index.copyFrontRemoved());
|
return this->m_range.propertyByIndex(index.copyFrontRemoved());
|
||||||
|
case IndexIsInRange:
|
||||||
|
return CVariant::fromValue(isInRange());
|
||||||
case IndexAtis:
|
case IndexAtis:
|
||||||
return this->m_atis.propertyByIndex(index.copyFrontRemoved());
|
return this->m_atis.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexMetar:
|
case IndexMetar:
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace BlackMisc
|
|||||||
IndexFrequency,
|
IndexFrequency,
|
||||||
IndexPosition,
|
IndexPosition,
|
||||||
IndexRange,
|
IndexRange,
|
||||||
|
IndexIsInRange,
|
||||||
IndexDistanceToOwnAircraft,
|
IndexDistanceToOwnAircraft,
|
||||||
IndexIsOnline,
|
IndexIsOnline,
|
||||||
IndexBookedFrom,
|
IndexBookedFrom,
|
||||||
@@ -70,10 +71,7 @@ namespace BlackMisc
|
|||||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||||
|
|
||||||
//! Has booking times?
|
//! Has booking times?
|
||||||
bool hasBookingTimes() const
|
bool hasBookingTimes() const;
|
||||||
{
|
|
||||||
return !(this->m_bookedFromUtc.isNull() && this->m_bookedUntilUtc.isNull());
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Has ATIS?
|
//! Has ATIS?
|
||||||
bool hasAtis() const
|
bool hasAtis() const
|
||||||
@@ -135,10 +133,8 @@ namespace BlackMisc
|
|||||||
//! Set position
|
//! Set position
|
||||||
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_position = position; }
|
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_position = position; }
|
||||||
|
|
||||||
/*!
|
//! Syncronize controller data
|
||||||
* Syncronize controller data
|
//! Updates two stations (namely a booked and online ATC station) with complementary data
|
||||||
* Updates two stations (namely a booked and online ATC station) with complementary data
|
|
||||||
*/
|
|
||||||
void syncronizeControllerData(CAtcStation &otherStation);
|
void syncronizeControllerData(CAtcStation &otherStation);
|
||||||
|
|
||||||
//! Get the radius of the controller's area of visibility.
|
//! Get the radius of the controller's area of visibility.
|
||||||
@@ -147,6 +143,9 @@ namespace BlackMisc
|
|||||||
//! Set range
|
//! Set range
|
||||||
void setRange(const BlackMisc::PhysicalQuantities::CLength &range) { this->m_range = range; }
|
void setRange(const BlackMisc::PhysicalQuantities::CLength &range) { this->m_range = range; }
|
||||||
|
|
||||||
|
//! In range? If range and distance to own aircraft are not available false
|
||||||
|
bool isInRange() const;
|
||||||
|
|
||||||
//! Is station online (or just booked)?
|
//! Is station online (or just booked)?
|
||||||
bool isOnline() const { return m_isOnline; }
|
bool isOnline() const { return m_isOnline; }
|
||||||
|
|
||||||
@@ -165,50 +164,33 @@ namespace BlackMisc
|
|||||||
//! Valid voice room?
|
//! Valid voice room?
|
||||||
bool hasValidVoiceRoom() const { return this->m_voiceRoom.isValid(); }
|
bool hasValidVoiceRoom() const { return this->m_voiceRoom.isValid(); }
|
||||||
|
|
||||||
/*!
|
//! Booked date/time if any.
|
||||||
* Booked date/time if any.
|
//! This represents the closest booking within a time frame as there can be multiple bookings.
|
||||||
* This represents the closest booking within a time frame as there can be multiple bookings.
|
|
||||||
*/
|
|
||||||
const QDateTime &getBookedFromUtc() const { return m_bookedFromUtc; }
|
const QDateTime &getBookedFromUtc() const { return m_bookedFromUtc; }
|
||||||
|
|
||||||
|
//! Booked date/time if any.
|
||||||
|
//! This represents the closest booking within a time frame as there can be multiple bookings.
|
||||||
|
const QDateTime &getBookedUntilUtc() const { return m_bookedUntilUtc; }
|
||||||
|
|
||||||
|
//! Has valid booking times?
|
||||||
|
bool hasValidBookingTimes() const;
|
||||||
|
|
||||||
//! Set booked from
|
//! Set booked from
|
||||||
void setBookedFromUtc(const QDateTime &from) { this->m_bookedFromUtc = from; }
|
void setBookedFromUtc(const QDateTime &from) { this->m_bookedFromUtc = from; }
|
||||||
|
|
||||||
/*!
|
|
||||||
* Booked date/time if any.
|
|
||||||
* This represents the closest booking within a time frame as there can be multiple bookings.
|
|
||||||
*/
|
|
||||||
const QDateTime &getBookedUntilUtc() const { return m_bookedUntilUtc; }
|
|
||||||
|
|
||||||
//! Has valid booking times?
|
|
||||||
bool hasValidBookingTimes() const
|
|
||||||
{
|
|
||||||
return !this->m_bookedFromUtc.isNull() && this->m_bookedFromUtc.isValid() &&
|
|
||||||
!this->m_bookedUntilUtc.isNull() && this->m_bookedUntilUtc.isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Transfer booking times
|
//! Transfer booking times
|
||||||
void setBookedFromUntil(const CAtcStation &otherStation)
|
void setBookedFromUntil(const CAtcStation &otherStation);
|
||||||
{
|
|
||||||
this->setBookedFromUtc(otherStation.getBookedFromUtc());
|
|
||||||
this->setBookedUntilUtc(otherStation.getBookedUntilUtc());
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Booked now?
|
//! Booked now?
|
||||||
bool isBookedNow() const;
|
bool isBookedNow() const;
|
||||||
|
|
||||||
//! Tuned in within 25KHz channel spacing
|
//! Tuned in within 25KHz channel spacing
|
||||||
bool isComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const
|
bool isComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||||
{
|
|
||||||
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
//! When booked, 0 means now,
|
||||||
* When booked, 0 means now,
|
//! negative values mean booking in past,
|
||||||
* negative values mean booking in past,
|
//! positive values mean booking in future,
|
||||||
* positive values mean booking in future,
|
//! no booking dates will result in null time
|
||||||
* no booking dates will result in - 1 year
|
|
||||||
*/
|
|
||||||
BlackMisc::PhysicalQuantities::CTime bookedWhen() const;
|
BlackMisc::PhysicalQuantities::CTime bookedWhen() const;
|
||||||
|
|
||||||
//! Get ATIS
|
//! Get ATIS
|
||||||
@@ -282,7 +264,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAtcStation, (
|
|||||||
o.m_voiceRoom,
|
o.m_voiceRoom,
|
||||||
o.m_distanceToOwnAircraft,
|
o.m_distanceToOwnAircraft,
|
||||||
o.m_bearingToOwnAircraft
|
o.m_bearingToOwnAircraft
|
||||||
))
|
))
|
||||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAtcStation)
|
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAtcStation)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
||||||
{
|
{
|
||||||
// same coordinate results in 0 distance
|
// same coordinates results in 0 distance
|
||||||
if (coordinate1.latitude() == coordinate2.latitude() && coordinate1.longitude() == coordinate2.longitude())
|
if (coordinate1.latitude() == coordinate2.latitude() && coordinate1.longitude() == coordinate2.longitude())
|
||||||
{
|
{
|
||||||
return CLength(0, CLengthUnit::m());
|
return CLength(0, CLengthUnit::m());
|
||||||
@@ -58,6 +58,7 @@ namespace BlackMisc
|
|||||||
double c = 2.0 * qAtan(qSqrt(a) / qSqrt(1.0 - a));
|
double c = 2.0 * qAtan(qSqrt(a) / qSqrt(1.0 - a));
|
||||||
double distance = earthRadiusM * c;
|
double distance = earthRadiusM * c;
|
||||||
|
|
||||||
|
Q_ASSERT_X(distance >= 0, Q_FUNC_INFO, "distance < 0");
|
||||||
return CLength(distance, CLengthUnit::m());
|
return CLength(distance, CLengthUnit::m());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ namespace BlackMisc
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
ICoordinateWithRelativePosition();
|
ICoordinateWithRelativePosition();
|
||||||
|
|
||||||
BlackMisc::PhysicalQuantities::CAngle m_bearingToOwnAircraft; //!< temporary stored value
|
BlackMisc::PhysicalQuantities::CAngle m_bearingToOwnAircraft {0.0, BlackMisc::PhysicalQuantities::CAngleUnit::nullUnit()}; //!< temporary stored value
|
||||||
BlackMisc::PhysicalQuantities::CLength m_distanceToOwnAircraft; //!< temporary stored value
|
BlackMisc::PhysicalQuantities::CLength m_distanceToOwnAircraft {0.0, BlackMisc::PhysicalQuantities::CLengthUnit::nullUnit()}; //!< temporary stored value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user