mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
Ref T270, made lights comparable and use it with parts
This commit is contained in:
@@ -28,12 +28,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->addTimestampOffsetColumns();
|
this->addTimestampOffsetColumns();
|
||||||
|
|
||||||
m_columns.addColumn(CColumn("gnd.", CAircraftParts::IndexOnGround, new CBoolIconFormatter("on gnd.", "not on gnd.")));
|
m_columns.addColumn(CColumn("gnd.", CAircraftParts::IndexIsOnGround, new CBoolIconFormatter("on gnd.", "not on gnd.")));
|
||||||
m_columns.addColumn(CColumn("gear", CAircraftParts::IndexGearDown, new CBoolIconFormatter("gear down", "gear up")));
|
m_columns.addColumn(CColumn("gear", CAircraftParts::IndexGearDown, new CBoolIconFormatter("gear down", "gear up")));
|
||||||
m_columns.addColumn(CColumn("spoilers", CAircraftParts::IndexSpoilersOut, new CBoolIconFormatter("spoilers", "no spoilers")));
|
m_columns.addColumn(CColumn("spoilers", CAircraftParts::IndexSpoilersOut, new CBoolIconFormatter("spoilers", "no spoilers")));
|
||||||
m_columns.addColumn(CColumn("flaps", CAircraftParts::IndexFlapsPercentage, new CIntegerFormatter()));
|
m_columns.addColumn(CColumn("flaps", CAircraftParts::IndexFlapsPercentage, new CIntegerFormatter()));
|
||||||
|
|
||||||
m_columns.addColumn(CColumn::standardString("engines", { CAircraftParts::IndexEngines, CAircraftParts::IndexString }));
|
m_columns.addColumn(CColumn::standardString("engines", CAircraftParts::IndexEnginesAsString));
|
||||||
m_columns.addColumn(CColumn::standardString("lights", { CAircraftParts::IndexLights, CAircraftParts::IndexString }));
|
m_columns.addColumn(CColumn::standardString("lights", { CAircraftParts::IndexLights, CAircraftParts::IndexString }));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "blackmisc/aviation/aircraftlights.h"
|
#include "blackmisc/aviation/aircraftlights.h"
|
||||||
#include "blackmisc/aviation/aircraftsituation.h"
|
#include "blackmisc/aviation/aircraftsituation.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
#include "blackmisc/comparefunctions.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
|
||||||
@@ -137,6 +138,24 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CAircraftLights::comparePropertyByIndex(const CPropertyIndex &index, const CAircraftLights &compareValue) const
|
||||||
|
{
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexBeacon: return Compare::compare(m_beaconOn, compareValue.isBeaconOn());
|
||||||
|
case IndexLanding: return Compare::compare(m_landingOn, compareValue.isLandingOn());
|
||||||
|
case IndexLogo: return Compare::compare(m_logoOn, compareValue.isLogoOn());
|
||||||
|
case IndexNav: return Compare::compare(m_navOn, compareValue.isNavOn());
|
||||||
|
case IndexStrobe: return Compare::compare(m_strobeOn, compareValue.isStrobeOn());
|
||||||
|
case IndexTaxi: return Compare::compare(m_taxiOn, compareValue.isTaxiOn());
|
||||||
|
case IndexCabin: return Compare::compare(m_cabin, compareValue.isCabinOn());
|
||||||
|
case IndexRecognition: return Compare::compare(m_recognition, compareValue.isRecognitionOn());
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return INullable::comparePropertyByIndex(index.copyFrontRemoved(), compareValue);
|
||||||
|
}
|
||||||
|
|
||||||
void CAircraftLights::setAllOn()
|
void CAircraftLights::setAllOn()
|
||||||
{
|
{
|
||||||
m_beaconOn = true;
|
m_beaconOn = true;
|
||||||
|
|||||||
@@ -117,10 +117,13 @@ namespace BlackMisc
|
|||||||
void guessLights(const CAircraftSituation &situation);
|
void guessLights(const CAircraftSituation &situation);
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
|
//! Compare by index
|
||||||
|
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftLights &compareValue) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|||||||
@@ -223,10 +223,12 @@ namespace BlackMisc
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexEngines: return CVariant::fromValue(m_engines);
|
case IndexEngines: return CVariant::fromValue(m_engines);
|
||||||
|
case IndexEnginesAsString: return CVariant::fromValue(m_engines.toQString(true));
|
||||||
case IndexFlapsPercentage: return CVariant::fromValue(m_flapsPercentage);
|
case IndexFlapsPercentage: return CVariant::fromValue(m_flapsPercentage);
|
||||||
case IndexGearDown: return CVariant::fromValue(m_gearDown);
|
case IndexGearDown: return CVariant::fromValue(m_gearDown);
|
||||||
case IndexLights: return m_lights.propertyByIndex(index.copyFrontRemoved());
|
case IndexLights: return m_lights.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexSpoilersOut: return CVariant::fromValue(m_spoilersOut);
|
case IndexSpoilersOut: return CVariant::fromValue(m_spoilersOut);
|
||||||
|
case IndexIsOnGround: return CVariant::fromValue(m_isOnGround);
|
||||||
default: return CValueObject::propertyByIndex(index);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,11 +241,12 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexEngines: m_engines = variant.to < decltype(m_engines) > (); break;
|
case IndexEngines: m_engines = variant.to<decltype(m_engines)> (); break;
|
||||||
case IndexFlapsPercentage: m_flapsPercentage = variant.toInt(); break;
|
case IndexFlapsPercentage: m_flapsPercentage = variant.toInt(); break;
|
||||||
case IndexGearDown: m_gearDown = variant.toBool(); break;
|
case IndexGearDown: m_gearDown = variant.toBool(); break;
|
||||||
case IndexLights: m_lights.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
case IndexLights: m_lights.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||||
case IndexSpoilersOut: m_spoilersOut = variant.toBool(); break;
|
case IndexSpoilersOut: m_spoilersOut = variant.toBool(); break;
|
||||||
|
case IndexIsOnGround: m_isOnGround = variant.toBool(); break;
|
||||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,7 +263,8 @@ namespace BlackMisc
|
|||||||
case IndexFlapsPercentage: return Compare::compare(m_flapsPercentage, compareValue.getFlapsPercent());
|
case IndexFlapsPercentage: return Compare::compare(m_flapsPercentage, compareValue.getFlapsPercent());
|
||||||
case IndexGearDown: return Compare::compare(m_gearDown, compareValue.isGearDown());
|
case IndexGearDown: return Compare::compare(m_gearDown, compareValue.isGearDown());
|
||||||
case IndexSpoilersOut: return Compare::compare(m_spoilersOut, compareValue.isSpoilersOut());
|
case IndexSpoilersOut: return Compare::compare(m_spoilersOut, compareValue.isSpoilersOut());
|
||||||
case IndexLights:
|
case IndexIsOnGround: return Compare::compare(m_isOnGround, compareValue.isOnGround());
|
||||||
|
case IndexLights: return m_lights.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getLights());
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ namespace BlackMisc
|
|||||||
IndexFlapsPercentage,
|
IndexFlapsPercentage,
|
||||||
IndexSpoilersOut,
|
IndexSpoilersOut,
|
||||||
IndexEngines,
|
IndexEngines,
|
||||||
IndexOnGround
|
IndexEnginesAsString,
|
||||||
|
IndexIsOnGround
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Parts Details
|
//! Parts Details
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexIsNull = BlackMisc::CPropertyIndex::GlobalIndexINullable,
|
IndexIsNull = CPropertyIndex::GlobalIndexINullable,
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor, init to null
|
//! Constructor, init to null
|
||||||
|
|||||||
Reference in New Issue
Block a user