mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T275, aligned classes with new "comparePropertyByIndex" in base class
This commit is contained in:
@@ -579,40 +579,23 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftDesignator:
|
||||
return CVariant::fromValue(m_designator);
|
||||
case IndexIataCode:
|
||||
return CVariant::fromValue(m_iataCode);
|
||||
case IndexFamily:
|
||||
return CVariant::fromValue(m_family);
|
||||
case IndexCombinedAircraftType:
|
||||
return CVariant::fromValue(m_combinedType);
|
||||
case IndexModelDescription:
|
||||
return CVariant::fromValue(m_modelDescription);
|
||||
case IndexModelIataDescription:
|
||||
return CVariant::fromValue(m_modelIataDescription);
|
||||
case IndexModelSwiftDescription:
|
||||
return CVariant::fromValue(m_modelSwiftDescription);
|
||||
case IndexCombinedDescription:
|
||||
return CVariant::fromValue(this->getCombinedModelDescription());
|
||||
case IndexManufacturer:
|
||||
return CVariant::fromValue(m_manufacturer);
|
||||
case IndexWtc:
|
||||
return CVariant::fromValue(m_wtc);
|
||||
case IndexIsVtol:
|
||||
return CVariant::fromValue(this->isVtol());
|
||||
case IndexIsLegacy:
|
||||
return CVariant::fromValue(m_legacy);
|
||||
case IndexIsMilitary:
|
||||
return CVariant::fromValue(m_military);
|
||||
case IndexIsRealworld:
|
||||
return CVariant::fromValue(m_realWorld);
|
||||
case IndexRank:
|
||||
return CVariant::fromValue(m_rank);
|
||||
case IndexDesignatorManufacturer:
|
||||
return CVariant::fromValue(this->getDesignatorManufacturer());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexAircraftDesignator: return CVariant::fromValue(m_designator);
|
||||
case IndexIataCode: return CVariant::fromValue(m_iataCode);
|
||||
case IndexFamily: return CVariant::fromValue(m_family);
|
||||
case IndexCombinedAircraftType: return CVariant::fromValue(m_combinedType);
|
||||
case IndexModelDescription: return CVariant::fromValue(m_modelDescription);
|
||||
case IndexModelIataDescription: return CVariant::fromValue(m_modelIataDescription);
|
||||
case IndexModelSwiftDescription: return CVariant::fromValue(m_modelSwiftDescription);
|
||||
case IndexCombinedDescription: return CVariant::fromValue(this->getCombinedModelDescription());
|
||||
case IndexManufacturer: return CVariant::fromValue(m_manufacturer);
|
||||
case IndexWtc: return CVariant::fromValue(m_wtc);
|
||||
case IndexIsVtol: return CVariant::fromValue(this->isVtol());
|
||||
case IndexIsLegacy: return CVariant::fromValue(m_legacy);
|
||||
case IndexIsMilitary: return CVariant::fromValue(m_military);
|
||||
case IndexIsRealworld: return CVariant::fromValue(m_realWorld);
|
||||
case IndexRank: return CVariant::fromValue(m_rank);
|
||||
case IndexDesignatorManufacturer: return CVariant::fromValue(this->getDesignatorManufacturer());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,45 +606,19 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftDesignator:
|
||||
this->setDesignator(variant.value<QString>());
|
||||
break;
|
||||
case IndexIataCode:
|
||||
this->setIataCode(variant.value<QString>());
|
||||
break;
|
||||
case IndexFamily:
|
||||
this->setFamily(variant.value<QString>());
|
||||
break;
|
||||
case IndexCombinedAircraftType:
|
||||
this->setCombinedType(variant.value<QString>());
|
||||
break;
|
||||
case IndexModelDescription:
|
||||
this->setModelDescription(variant.value<QString>());
|
||||
break;
|
||||
case IndexModelIataDescription:
|
||||
this->setModelIataDescription(variant.value<QString>());
|
||||
break;
|
||||
case IndexModelSwiftDescription:
|
||||
this->setModelSwiftDescription(variant.value<QString>());
|
||||
break;
|
||||
case IndexManufacturer:
|
||||
this->setManufacturer(variant.value<QString>());
|
||||
break;
|
||||
case IndexWtc:
|
||||
this->setWtc(variant.value<QString>());
|
||||
break;
|
||||
case IndexIsLegacy:
|
||||
m_legacy = variant.toBool();
|
||||
break;
|
||||
case IndexIsMilitary:
|
||||
m_military = variant.toBool();
|
||||
break;
|
||||
case IndexRank:
|
||||
m_rank = variant.toInt();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexAircraftDesignator: this->setDesignator(variant.value<QString>()); break;
|
||||
case IndexIataCode: this->setIataCode(variant.value<QString>()); break;
|
||||
case IndexFamily: this->setFamily(variant.value<QString>()); break;
|
||||
case IndexCombinedAircraftType: this->setCombinedType(variant.value<QString>()); break;
|
||||
case IndexModelDescription: this->setModelDescription(variant.value<QString>()); break;
|
||||
case IndexModelIataDescription: this->setModelIataDescription(variant.value<QString>()); break;
|
||||
case IndexModelSwiftDescription: this->setModelSwiftDescription(variant.value<QString>()); break;
|
||||
case IndexManufacturer: this->setManufacturer(variant.value<QString>()); break;
|
||||
case IndexWtc: this->setWtc(variant.value<QString>()); break;
|
||||
case IndexIsLegacy: m_legacy = variant.toBool(); break;
|
||||
case IndexIsMilitary: m_military = variant.toBool(); break;
|
||||
case IndexRank: m_rank = variant.toInt(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,23 +626,16 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive); }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftDesignator:
|
||||
return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive);
|
||||
case IndexIataCode:
|
||||
return m_iataCode.compare(compareValue.getIataCode(), Qt::CaseInsensitive);
|
||||
case IndexFamily:
|
||||
return m_family.compare(compareValue.getFamily(), Qt::CaseInsensitive);
|
||||
case IndexCombinedAircraftType:
|
||||
return m_combinedType.compare(compareValue.getCombinedType(), Qt::CaseInsensitive);
|
||||
case IndexModelDescription:
|
||||
return m_modelDescription.compare(compareValue.getModelDescription(), Qt::CaseInsensitive);
|
||||
case IndexModelIataDescription:
|
||||
return m_modelIataDescription.compare(compareValue.getModelIataDescription(), Qt::CaseInsensitive);
|
||||
case IndexModelSwiftDescription:
|
||||
return m_modelSwiftDescription.compare(compareValue.getModelSwiftDescription(), Qt::CaseInsensitive);
|
||||
case IndexAircraftDesignator: return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive);
|
||||
case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode(), Qt::CaseInsensitive);
|
||||
case IndexFamily: return m_family.compare(compareValue.getFamily(), Qt::CaseInsensitive);
|
||||
case IndexCombinedAircraftType: return m_combinedType.compare(compareValue.getCombinedType(), Qt::CaseInsensitive);
|
||||
case IndexModelDescription: return m_modelDescription.compare(compareValue.getModelDescription(), Qt::CaseInsensitive);
|
||||
case IndexModelIataDescription: return m_modelIataDescription.compare(compareValue.getModelIataDescription(), Qt::CaseInsensitive);
|
||||
case IndexModelSwiftDescription: return m_modelSwiftDescription.compare(compareValue.getModelSwiftDescription(), Qt::CaseInsensitive);
|
||||
case IndexCombinedDescription:
|
||||
{
|
||||
// compare without generating new strings
|
||||
@@ -700,24 +650,15 @@ namespace BlackMisc
|
||||
}
|
||||
return c;
|
||||
}
|
||||
case IndexManufacturer:
|
||||
return m_manufacturer.compare(compareValue.getManufacturer(), Qt::CaseInsensitive);
|
||||
case IndexWtc:
|
||||
return m_wtc.compare(compareValue.getWtc(), Qt::CaseInsensitive);
|
||||
case IndexIsLegacy:
|
||||
return Compare::compare(m_legacy, compareValue.isLegacyAircraft());
|
||||
case IndexIsMilitary:
|
||||
return Compare::compare(m_military, compareValue.isMilitary());
|
||||
case IndexIsVtol:
|
||||
return Compare::compare(isVtol(), compareValue.isVtol());
|
||||
case IndexIsRealworld:
|
||||
return Compare::compare(m_realWorld, compareValue.isRealWorld());
|
||||
case IndexRank:
|
||||
return Compare::compare(m_rank, compareValue.getRank());
|
||||
case IndexDesignatorManufacturer:
|
||||
return getDesignatorManufacturer().compare(compareValue.getDesignatorManufacturer(), Qt::CaseInsensitive);
|
||||
default:
|
||||
break;
|
||||
case IndexManufacturer: return m_manufacturer.compare(compareValue.getManufacturer(), Qt::CaseInsensitive);
|
||||
case IndexWtc: return m_wtc.compare(compareValue.getWtc(), Qt::CaseInsensitive);
|
||||
case IndexIsLegacy: return Compare::compare(m_legacy, compareValue.isLegacyAircraft());
|
||||
case IndexIsMilitary: return Compare::compare(m_military, compareValue.isMilitary());
|
||||
case IndexIsVtol: return Compare::compare(isVtol(), compareValue.isVtol());
|
||||
case IndexIsRealworld: return Compare::compare(m_realWorld, compareValue.isRealWorld());
|
||||
case IndexRank: return Compare::compare(m_rank, compareValue.getRank());
|
||||
case IndexDesignatorManufacturer: return getDesignatorManufacturer().compare(compareValue.getDesignatorManufacturer(), Qt::CaseInsensitive);
|
||||
default: return CValueObject::comparePropertyByIndex(index, *this);
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftIcaoCode &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace BlackMisc
|
||||
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare by index
|
||||
//! \copydoc Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituation &compareValue) const;
|
||||
|
||||
//! Get position
|
||||
|
||||
@@ -314,37 +314,23 @@ namespace BlackMisc
|
||||
CVariant CAtcStation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBookedFrom:
|
||||
return CVariant::from(m_bookedFromUtc);
|
||||
case IndexBookedUntil:
|
||||
return CVariant::from(m_bookedUntilUtc);
|
||||
case IndexCallsign:
|
||||
return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexController:
|
||||
return m_controller.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexFrequency:
|
||||
return m_frequency.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsOnline:
|
||||
return CVariant::from(m_isOnline);
|
||||
case IndexLatitude:
|
||||
return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitude:
|
||||
return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPosition:
|
||||
return m_position.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRange:
|
||||
return m_range.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsInRange:
|
||||
return CVariant::fromValue(isInRange());
|
||||
case IndexAtis:
|
||||
return m_atis.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexMetar:
|
||||
return m_metar.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceRoom:
|
||||
return m_voiceRoom.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexBookedFrom: return CVariant::from(m_bookedFromUtc);
|
||||
case IndexBookedUntil: return CVariant::from(m_bookedUntilUtc);
|
||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexController: return m_controller.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexFrequency: return m_frequency.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsOnline: return CVariant::from(m_isOnline);
|
||||
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPosition: return m_position.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRange: return m_range.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsInRange: return CVariant::fromValue(isInRange());
|
||||
case IndexAtis: return m_atis.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexMetar: return m_metar.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexVoiceRoom: return m_voiceRoom.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
|
||||
ICoordinateWithRelativePosition::propertyByIndex(index) :
|
||||
@@ -355,7 +341,7 @@ namespace BlackMisc
|
||||
void CAtcStation::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAtcStation>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBookedFrom:
|
||||
@@ -407,43 +393,29 @@ namespace BlackMisc
|
||||
int CAtcStation::comparePropertyByIndex(const CPropertyIndex &index, const CAtcStation &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return this->getCallsign().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBookedFrom:
|
||||
return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc());
|
||||
case IndexBookedUntil:
|
||||
return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc());
|
||||
case IndexCallsign:
|
||||
return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexController:
|
||||
return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController());
|
||||
case IndexFrequency:
|
||||
return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency());
|
||||
case IndexIsOnline:
|
||||
return Compare::compare(this->isOnline(), compareValue.isOnline());
|
||||
case IndexLatitude:
|
||||
return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||
case IndexLongitude:
|
||||
return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||
case IndexPosition:
|
||||
return m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
||||
case IndexRange:
|
||||
return m_range.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRange());
|
||||
case IndexIsInRange:
|
||||
return Compare::compare(this->isInRange(), compareValue.isInRange());
|
||||
case IndexAtis:
|
||||
return m_atis.getMessage().compare(compareValue.getAtis().getMessage());
|
||||
case IndexMetar:
|
||||
return m_metar.getMessage().compare(compareValue.getMetar().getMessage());
|
||||
case IndexVoiceRoom:
|
||||
return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl());
|
||||
case IndexBookedFrom: return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc());
|
||||
case IndexBookedUntil: return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc());
|
||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexController: return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController());
|
||||
case IndexFrequency: return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency());
|
||||
case IndexIsOnline: return Compare::compare(this->isOnline(), compareValue.isOnline());
|
||||
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||
case IndexPosition: return m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
||||
case IndexRange: return m_range.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRange());
|
||||
case IndexIsInRange: return Compare::compare(this->isInRange(), compareValue.isInRange());
|
||||
case IndexAtis: return m_atis.getMessage().compare(compareValue.getAtis().getMessage());
|
||||
case IndexMetar: return m_metar.getMessage().compare(compareValue.getMetar().getMessage());
|
||||
case IndexVoiceRoom: return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl());
|
||||
default:
|
||||
if (ICoordinateWithRelativePosition::canHandleIndex(index))
|
||||
{
|
||||
return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
|
||||
}
|
||||
break;
|
||||
return CValueObject::comparePropertyByIndex(index, *this);
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user