mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #780, fixed property index compare issues found in the client
This commit is contained in:
@@ -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<ColumnIndex>();
|
||||
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<ColumnIndex>();
|
||||
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());
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
template <class AVIO>
|
||||
bool CModulator<AVIO>::isDefaultValue() const
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,9 @@ namespace BlackMisc
|
||||
IndexCombinedIcaoLiveryStringNetworkModel,
|
||||
IndexModel,
|
||||
IndexNetworkModel,
|
||||
IndexNetworkModelAircraftIcaoDifference,
|
||||
IndexNetworkModelAirlineIcaoDifference,
|
||||
IndexNetworkModelLiveryDifference,
|
||||
IndexEnabled,
|
||||
IndexRendered,
|
||||
IndexPartsSynchronized,
|
||||
|
||||
Reference in New Issue
Block a user