Ref T275, aligned classes with new "comparePropertyByIndex" in base class

This commit is contained in:
Klaus Basan
2018-06-10 02:11:39 +02:00
parent de3cb71706
commit 169dca8d84
4 changed files with 81 additions and 168 deletions

View File

@@ -579,40 +579,23 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAircraftDesignator: case IndexAircraftDesignator: return CVariant::fromValue(m_designator);
return CVariant::fromValue(m_designator); case IndexIataCode: return CVariant::fromValue(m_iataCode);
case IndexIataCode: case IndexFamily: return CVariant::fromValue(m_family);
return CVariant::fromValue(m_iataCode); case IndexCombinedAircraftType: return CVariant::fromValue(m_combinedType);
case IndexFamily: case IndexModelDescription: return CVariant::fromValue(m_modelDescription);
return CVariant::fromValue(m_family); case IndexModelIataDescription: return CVariant::fromValue(m_modelIataDescription);
case IndexCombinedAircraftType: case IndexModelSwiftDescription: return CVariant::fromValue(m_modelSwiftDescription);
return CVariant::fromValue(m_combinedType); case IndexCombinedDescription: return CVariant::fromValue(this->getCombinedModelDescription());
case IndexModelDescription: case IndexManufacturer: return CVariant::fromValue(m_manufacturer);
return CVariant::fromValue(m_modelDescription); case IndexWtc: return CVariant::fromValue(m_wtc);
case IndexModelIataDescription: case IndexIsVtol: return CVariant::fromValue(this->isVtol());
return CVariant::fromValue(m_modelIataDescription); case IndexIsLegacy: return CVariant::fromValue(m_legacy);
case IndexModelSwiftDescription: case IndexIsMilitary: return CVariant::fromValue(m_military);
return CVariant::fromValue(m_modelSwiftDescription); case IndexIsRealworld: return CVariant::fromValue(m_realWorld);
case IndexCombinedDescription: case IndexRank: return CVariant::fromValue(m_rank);
return CVariant::fromValue(this->getCombinedModelDescription()); case IndexDesignatorManufacturer: return CVariant::fromValue(this->getDesignatorManufacturer());
case IndexManufacturer: default: return CValueObject::propertyByIndex(index);
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>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAircraftDesignator: case IndexAircraftDesignator: this->setDesignator(variant.value<QString>()); break;
this->setDesignator(variant.value<QString>()); case IndexIataCode: this->setIataCode(variant.value<QString>()); break;
break; case IndexFamily: this->setFamily(variant.value<QString>()); break;
case IndexIataCode: case IndexCombinedAircraftType: this->setCombinedType(variant.value<QString>()); break;
this->setIataCode(variant.value<QString>()); case IndexModelDescription: this->setModelDescription(variant.value<QString>()); break;
break; case IndexModelIataDescription: this->setModelIataDescription(variant.value<QString>()); break;
case IndexFamily: case IndexModelSwiftDescription: this->setModelSwiftDescription(variant.value<QString>()); break;
this->setFamily(variant.value<QString>()); case IndexManufacturer: this->setManufacturer(variant.value<QString>()); break;
break; case IndexWtc: this->setWtc(variant.value<QString>()); break;
case IndexCombinedAircraftType: case IndexIsLegacy: m_legacy = variant.toBool(); break;
this->setCombinedType(variant.value<QString>()); case IndexIsMilitary: m_military = variant.toBool(); break;
break; case IndexRank: m_rank = variant.toInt(); break;
case IndexModelDescription: default: CValueObject::setPropertyByIndex(index, variant); break;
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 (index.isMyself()) { return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive); }
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);} if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexAircraftDesignator: case IndexAircraftDesignator: return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive);
return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive); case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode(), Qt::CaseInsensitive);
case IndexIataCode: case IndexFamily: return m_family.compare(compareValue.getFamily(), Qt::CaseInsensitive);
return m_iataCode.compare(compareValue.getIataCode(), Qt::CaseInsensitive); case IndexCombinedAircraftType: return m_combinedType.compare(compareValue.getCombinedType(), Qt::CaseInsensitive);
case IndexFamily: case IndexModelDescription: return m_modelDescription.compare(compareValue.getModelDescription(), Qt::CaseInsensitive);
return m_family.compare(compareValue.getFamily(), Qt::CaseInsensitive); case IndexModelIataDescription: return m_modelIataDescription.compare(compareValue.getModelIataDescription(), Qt::CaseInsensitive);
case IndexCombinedAircraftType: case IndexModelSwiftDescription: return m_modelSwiftDescription.compare(compareValue.getModelSwiftDescription(), Qt::CaseInsensitive);
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: case IndexCombinedDescription:
{ {
// compare without generating new strings // compare without generating new strings
@@ -700,24 +650,15 @@ namespace BlackMisc
} }
return c; return c;
} }
case IndexManufacturer: case IndexManufacturer: return m_manufacturer.compare(compareValue.getManufacturer(), Qt::CaseInsensitive);
return m_manufacturer.compare(compareValue.getManufacturer(), Qt::CaseInsensitive); case IndexWtc: return m_wtc.compare(compareValue.getWtc(), Qt::CaseInsensitive);
case IndexWtc: case IndexIsLegacy: return Compare::compare(m_legacy, compareValue.isLegacyAircraft());
return m_wtc.compare(compareValue.getWtc(), Qt::CaseInsensitive); case IndexIsMilitary: return Compare::compare(m_military, compareValue.isMilitary());
case IndexIsLegacy: case IndexIsVtol: return Compare::compare(isVtol(), compareValue.isVtol());
return Compare::compare(m_legacy, compareValue.isLegacyAircraft()); case IndexIsRealworld: return Compare::compare(m_realWorld, compareValue.isRealWorld());
case IndexIsMilitary: case IndexRank: return Compare::compare(m_rank, compareValue.getRank());
return Compare::compare(m_military, compareValue.isMilitary()); case IndexDesignatorManufacturer: return getDesignatorManufacturer().compare(compareValue.getDesignatorManufacturer(), Qt::CaseInsensitive);
case IndexIsVtol: default: return CValueObject::comparePropertyByIndex(index, *this);
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;
} }
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison"); Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
return 0; return 0;

View File

@@ -276,7 +276,7 @@ namespace BlackMisc
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); 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; int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftIcaoCode &compareValue) const;
//! \copydoc BlackMisc::Mixin::String::toQString //! \copydoc BlackMisc::Mixin::String::toQString

View File

@@ -154,7 +154,7 @@ namespace BlackMisc
//! \copydoc Mixin::Index::setPropertyByIndex //! \copydoc Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant); void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! Compare by index //! \copydoc Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituation &compareValue) const; int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituation &compareValue) const;
//! Get position //! Get position

View File

@@ -314,37 +314,23 @@ namespace BlackMisc
CVariant CAtcStation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const CVariant CAtcStation::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{ {
if (index.isMyself()) { return CVariant::from(*this); } if (index.isMyself()) { return CVariant::from(*this); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexBookedFrom: case IndexBookedFrom: return CVariant::from(m_bookedFromUtc);
return CVariant::from(m_bookedFromUtc); case IndexBookedUntil: return CVariant::from(m_bookedUntilUtc);
case IndexBookedUntil: case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
return CVariant::from(m_bookedUntilUtc); case IndexController: return m_controller.propertyByIndex(index.copyFrontRemoved());
case IndexCallsign: case IndexFrequency: return m_frequency.propertyByIndex(index.copyFrontRemoved());
return m_callsign.propertyByIndex(index.copyFrontRemoved()); case IndexIsOnline: return CVariant::from(m_isOnline);
case IndexController: case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
return m_controller.propertyByIndex(index.copyFrontRemoved()); case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
case IndexFrequency: case IndexPosition: return m_position.propertyByIndex(index.copyFrontRemoved());
return m_frequency.propertyByIndex(index.copyFrontRemoved()); case IndexRange: return m_range.propertyByIndex(index.copyFrontRemoved());
case IndexIsOnline: case IndexIsInRange: return CVariant::fromValue(isInRange());
return CVariant::from(m_isOnline); case IndexAtis: return m_atis.propertyByIndex(index.copyFrontRemoved());
case IndexLatitude: case IndexMetar: return m_metar.propertyByIndex(index.copyFrontRemoved());
return this->latitude().propertyByIndex(index.copyFrontRemoved()); case IndexVoiceRoom: return m_voiceRoom.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: default:
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ? return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
ICoordinateWithRelativePosition::propertyByIndex(index) : ICoordinateWithRelativePosition::propertyByIndex(index) :
@@ -355,7 +341,7 @@ namespace BlackMisc
void CAtcStation::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) void CAtcStation::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
{ {
if (index.isMyself()) { (*this) = variant.to<CAtcStation>(); return; } if (index.isMyself()) { (*this) = variant.to<CAtcStation>(); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexBookedFrom: case IndexBookedFrom:
@@ -407,43 +393,29 @@ namespace BlackMisc
int CAtcStation::comparePropertyByIndex(const CPropertyIndex &index, const CAtcStation &compareValue) const int CAtcStation::comparePropertyByIndex(const CPropertyIndex &index, const CAtcStation &compareValue) const
{ {
if (index.isMyself()) { return this->getCallsign().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); } if (index.isMyself()) { return this->getCallsign().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexBookedFrom: case IndexBookedFrom: return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc());
return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc()); case IndexBookedUntil: return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc());
case IndexBookedUntil: case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc()); case IndexController: return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController());
case IndexCallsign: case IndexFrequency: return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency());
return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign()); case IndexIsOnline: return Compare::compare(this->isOnline(), compareValue.isOnline());
case IndexController: case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController()); case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
case IndexFrequency: case IndexPosition: return m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency()); case IndexRange: return m_range.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRange());
case IndexIsOnline: case IndexIsInRange: return Compare::compare(this->isInRange(), compareValue.isInRange());
return Compare::compare(this->isOnline(), compareValue.isOnline()); case IndexAtis: return m_atis.getMessage().compare(compareValue.getAtis().getMessage());
case IndexLatitude: case IndexMetar: return m_metar.getMessage().compare(compareValue.getMetar().getMessage());
return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude()); case IndexVoiceRoom: return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl());
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: default:
if (ICoordinateWithRelativePosition::canHandleIndex(index)) if (ICoordinateWithRelativePosition::canHandleIndex(index))
{ {
return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue); return ICoordinateWithRelativePosition::comparePropertyByIndex(index, compareValue);
} }
break; return CValueObject::comparePropertyByIndex(index, *this);
} }
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed"); Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
return 0; return 0;