diff --git a/src/blackgui/models/simulatedaircraftlistmodel.cpp b/src/blackgui/models/simulatedaircraftlistmodel.cpp index c9c55eaba..133b03c7f 100644 --- a/src/blackgui/models/simulatedaircraftlistmodel.cpp +++ b/src/blackgui/models/simulatedaircraftlistmodel.cpp @@ -64,7 +64,7 @@ namespace BlackGui this->m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CSimulatedAircraft::IndexPilot, CUser::IndexRealName })); this->m_columns.addColumn(CColumn("dist.", "distance", CSimulatedAircraft::IndexRelativeDistance, new CAirspaceDistanceFormatter())); this->m_columns.addColumn(CColumn("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, new CAltitudeFormatter())); - this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter())); + this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundSpeed }, new CAircraftSpeedFormatter())); this->m_columns.addColumn(CColumn::standardString("icao", "icao and livery info", { CSimulatedAircraft::IndexCombinedIcaoLiveryStringNetworkModel})); // icon column for airline @@ -90,7 +90,7 @@ namespace BlackGui this->m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", { CSimulatedAircraft::IndexCallsign, CCallsign::IndexCallsignString })); this->m_columns.addColumn(CColumn("dist.", "distance", CSimulatedAircraft::IndexRelativeDistance, new CAirspaceDistanceFormatter())); this->m_columns.addColumn(CColumn("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, new CAltitudeFormatter())); - this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter())); + this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundSpeed }, new CAircraftSpeedFormatter())); this->m_columns.addColumn(CColumn("p.", "parts", CSimulatedAircraft::IndexPartsSynchronized, new CBoolIconFormatter("parts", "no parts"), true)); this->m_columns.addColumn(CColumn("fp.", "fast position updates", CSimulatedAircraft::IndexFastPositionUpdates, new CBoolIconFormatter("enabled", "disabled"), true)); this->m_columns.addColumn(CColumn::standardString("realname", "pilot's real name", { CSimulatedAircraft::IndexPilot, CUser::IndexRealName })); diff --git a/src/blackmisc/aviation/aircraftsituation.cpp b/src/blackmisc/aviation/aircraftsituation.cpp index e222db486..f73f1e173 100644 --- a/src/blackmisc/aviation/aircraftsituation.cpp +++ b/src/blackmisc/aviation/aircraftsituation.cpp @@ -23,7 +23,6 @@ namespace BlackMisc { namespace Aviation { - CAircraftSituation::CAircraftSituation(const CCoordinateGeodetic &position, const CAltitude &altitude, const CHeading &heading, const CAngle &pitch, const CAngle &bank, const CSpeed &gs) : m_position(position), m_altitude(altitude), m_heading(heading), m_pitch(pitch), m_bank(bank), m_groundSpeed(gs) {} @@ -55,6 +54,10 @@ namespace BlackMisc { return ITimestampBased::propertyByIndex(index); } + if (ICoordinateGeodetic::canHandleIndex(index)) + { + return ICoordinateGeodetic::propertyByIndex(index); + } ColumnIndex i = index.frontCasted(); switch (i) @@ -73,7 +76,7 @@ namespace BlackMisc return this->m_pitch.propertyByIndex(index.copyFrontRemoved()); case IndexBank: return this->m_bank.propertyByIndex(index.copyFrontRemoved()); - case IndexGroundspeed: + case IndexGroundSpeed: return this->m_groundSpeed.propertyByIndex(index.copyFrontRemoved()); case IndexCallsign: return this->m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved()); @@ -106,7 +109,7 @@ namespace BlackMisc case IndexBank: this->m_bank.setPropertyByIndex(index.copyFrontRemoved(), variant); break; - case IndexGroundspeed: + case IndexGroundSpeed: this->m_groundSpeed.setPropertyByIndex(index.copyFrontRemoved(), variant); break; case IndexCallsign: @@ -118,6 +121,45 @@ namespace BlackMisc } } + int CAircraftSituation::comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituation &compareValue) const + { + if (ITimestampBased::canHandleIndex(index)) + { + return ITimestampBased::comparePropertyByIndex(index, compareValue); + } + if (ICoordinateGeodetic::canHandleIndex(index)) + { + return ICoordinateGeodetic::comparePropertyByIndex(index, compareValue); + } + ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexPosition: + return this->m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition()); + break; + case IndexAltitude: + return this->m_altitude.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAltitude()); + break; + case IndexPitch: + return this->m_pitch.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPitch()); + break; + case IndexBank: + return this->m_bank.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getBank()); + break; + case IndexGroundSpeed: + return this->m_groundSpeed.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getGroundSpeed()); + break; + case IndexCallsign: + return this->m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); + break; + default: + break; + } + const QString assertMsg("No comparison for index " + index.toQString()); + Q_ASSERT_X(false, Q_FUNC_INFO, assertMsg.toLocal8Bit().constData()); + return 0; + } + bool CAircraftSituation::isOnGroundGuessed() const { CLength heightAboveGround(this->getHeightAboveGround()); diff --git a/src/blackmisc/aviation/aircraftsituation.h b/src/blackmisc/aviation/aircraftsituation.h index 1aff28eb7..d9f550041 100644 --- a/src/blackmisc/aviation/aircraftsituation.h +++ b/src/blackmisc/aviation/aircraftsituation.h @@ -53,7 +53,7 @@ namespace BlackMisc IndexHeading, IndexBank, IndexPitch, - IndexGroundspeed, + IndexGroundSpeed, IndexCallsign }; @@ -81,6 +81,9 @@ namespace BlackMisc //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); + //! Compare by index + int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituation &compareValue) const; + //! Get position const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return this->m_position; } diff --git a/src/blackmisc/aviation/modulator.cpp b/src/blackmisc/aviation/modulator.cpp index a06dc123a..2bce9fbe6 100644 --- a/src/blackmisc/aviation/modulator.cpp +++ b/src/blackmisc/aviation/modulator.cpp @@ -25,7 +25,6 @@ namespace BlackMisc { namespace Aviation { - template bool CModulator::isDefaultValue() const { diff --git a/src/blackmisc/pq/physicalquantity.cpp b/src/blackmisc/pq/physicalquantity.cpp index cffe5ffe2..4313c34a4 100644 --- a/src/blackmisc/pq/physicalquantity.cpp +++ b/src/blackmisc/pq/physicalquantity.cpp @@ -15,6 +15,7 @@ #include "blackmisc/propertyindex.h" #include "blackmisc/propertyindexvariantmap.h" #include "blackmisc/variant.h" +#include "blackmisc/verify.h" #include "blackmisc/pq/length.h" #include "blackmisc/pq/pressure.h" #include "blackmisc/pq/frequency.h" @@ -428,7 +429,7 @@ namespace BlackMisc default: break; } - Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison"); + BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString())); return 0; } diff --git a/src/blackmisc/simulation/simulatedaircraft.cpp b/src/blackmisc/simulation/simulatedaircraft.cpp index c22adad32..31e2f9275 100644 --- a/src/blackmisc/simulation/simulatedaircraft.cpp +++ b/src/blackmisc/simulation/simulatedaircraft.cpp @@ -11,6 +11,7 @@ #include "blackmisc/comparefunctions.h" #include "blackmisc/metaclassprivate.h" #include "blackmisc/pq/constants.h" +#include "blackmisc/verify.h" #include "blackmisc/propertyindex.h" #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/stringutils.h" @@ -396,12 +397,13 @@ namespace BlackMisc case IndexPilot: return this->m_pilot.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPilot()); case IndexSituation: + return this->m_situation.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getSituation()); case IndexRelativeDistance: return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance()); case IndexCom1System: - return m_com1system.getFrequencyActive().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom1System().getFrequencyActive()); + return m_com1system.getFrequencyActive().comparePropertyByIndex(CPropertyIndex(), compareValue.getCom1System().getFrequencyActive()); case IndexCom2System: - return m_com2system.getFrequencyActive().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCom2System().getFrequencyActive()); + return m_com2system.getFrequencyActive().comparePropertyByIndex(CPropertyIndex(), compareValue.getCom2System().getFrequencyActive()); case IndexTransponder: return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode()); case IndexLivery: @@ -412,12 +414,22 @@ namespace BlackMisc return m_model.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel()); case IndexNetworkModel: return m_networkModel.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getModel()); + case IndexNetworkModelAircraftIcaoDifference: + return this->getNetworkModelAircraftIcaoDifference().compare(compareValue.getNetworkModelAircraftIcaoDifference()); + case IndexNetworkModelAirlineIcaoDifference: + return this->getNetworkModelAirlineIcaoDifference().compare(compareValue.getNetworkModelAirlineIcaoDifference()); + case IndexNetworkModelLiveryDifference: + return this->getNetworkModelLiveryDifference().compare(compareValue.getNetworkModelLiveryDifference()); case IndexRendered: return Compare::compare(this->m_rendered, compareValue.isRendered()); case IndexPartsSynchronized: return Compare::compare(this->m_partsSynchronized, compareValue.isPartsSynchronized()); case IndexFastPositionUpdates: return Compare::compare(this->m_fastPositionUpdates, compareValue.fastPositionUpdates()); + case IndexCombinedIcaoLiveryString: + return this->getCombinedIcaoLiveryString(false).compare(compareValue.getCombinedIcaoLiveryString(false)); + case IndexCombinedIcaoLiveryStringNetworkModel: + return this->getCombinedIcaoLiveryString(true).compare(compareValue.getCombinedIcaoLiveryString(true)); default: if (ICoordinateWithRelativePosition::canHandleIndex(index)) { @@ -425,7 +437,7 @@ namespace BlackMisc } break; } - Q_ASSERT_X(false, Q_FUNC_INFO, "Comapre failed"); + BLACK_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable("No comparison for index " + index.toQString())); return 0; } diff --git a/src/blackmisc/simulation/simulatedaircraft.h b/src/blackmisc/simulation/simulatedaircraft.h index 7b694c092..2e3f6d485 100644 --- a/src/blackmisc/simulation/simulatedaircraft.h +++ b/src/blackmisc/simulation/simulatedaircraft.h @@ -82,6 +82,9 @@ namespace BlackMisc IndexCombinedIcaoLiveryStringNetworkModel, IndexModel, IndexNetworkModel, + IndexNetworkModelAircraftIcaoDifference, + IndexNetworkModelAirlineIcaoDifference, + IndexNetworkModelLiveryDifference, IndexEnabled, IndexRendered, IndexPartsSynchronized,