mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Ref T182, livery/ICAO classed formatting
This commit is contained in:
@@ -138,6 +138,7 @@ namespace BlackMisc
|
||||
int score = 0;
|
||||
if (this->hasValidDesignator() && this->getDesignator() == otherCode.getDesignator())
|
||||
{
|
||||
// 0..65
|
||||
score += 50; // same designator
|
||||
|
||||
if (this->getRank() == 0) { score += 15; }
|
||||
|
||||
@@ -40,25 +40,25 @@ namespace BlackMisc
|
||||
CAirlineIcaoCode::CAirlineIcaoCode(const QString &airlineDesignator)
|
||||
: m_designator(airlineDesignator.trimmed().toUpper())
|
||||
{
|
||||
if (this->m_designator.length() == 4)
|
||||
if (m_designator.length() == 4)
|
||||
{
|
||||
this->setDesignator(this->m_designator);
|
||||
this->setDesignator(m_designator);
|
||||
}
|
||||
}
|
||||
|
||||
CAirlineIcaoCode::CAirlineIcaoCode(const QString &airlineDesignator, const QString &airlineName, const BlackMisc::CCountry &country, const QString &telephony, bool virtualAirline, bool operating)
|
||||
: m_designator(airlineDesignator.trimmed().toUpper()), m_name(airlineName), m_telephonyDesignator(telephony), m_country(country), m_isVa(virtualAirline), m_isOperating(operating)
|
||||
{
|
||||
if (this->m_designator.length() == 4)
|
||||
if (m_designator.length() == 4)
|
||||
{
|
||||
this->setDesignator(this->m_designator);
|
||||
this->setDesignator(m_designator);
|
||||
}
|
||||
}
|
||||
|
||||
const QString CAirlineIcaoCode::getVDesignator() const
|
||||
{
|
||||
if (!isVirtualAirline()) { return this->m_designator; }
|
||||
return QLatin1Char('V') % this->m_designator;
|
||||
if (!isVirtualAirline()) { return m_designator; }
|
||||
return QLatin1Char('V') % m_designator;
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getVDesignatorDbKey() const
|
||||
@@ -70,12 +70,12 @@ namespace BlackMisc
|
||||
|
||||
void CAirlineIcaoCode::setDesignator(const QString &icaoDesignator)
|
||||
{
|
||||
this->m_designator = icaoDesignator.trimmed().toUpper();
|
||||
if (this->m_designator.length() == 4 && this->m_designator.startsWith("V"))
|
||||
m_designator = icaoDesignator.trimmed().toUpper();
|
||||
if (m_designator.length() == 4 && m_designator.startsWith("V"))
|
||||
{
|
||||
// a virtual designator was provided
|
||||
this->setVirtualAirline(true);
|
||||
this->m_designator = this->m_designator.right(3);
|
||||
m_designator = m_designator.right(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace BlackMisc
|
||||
|
||||
bool CAirlineIcaoCode::hasValidCountry() const
|
||||
{
|
||||
return this->m_country.isValid();
|
||||
return m_country.isValid();
|
||||
}
|
||||
|
||||
bool CAirlineIcaoCode::hasValidDesignator() const
|
||||
@@ -104,13 +104,13 @@ namespace BlackMisc
|
||||
|
||||
bool CAirlineIcaoCode::hasIataCode() const
|
||||
{
|
||||
return !this->m_iataCode.isEmpty();
|
||||
return !m_iataCode.isEmpty();
|
||||
}
|
||||
|
||||
bool CAirlineIcaoCode::matchesDesignator(const QString &designator) const
|
||||
{
|
||||
if (designator.isEmpty()) { return false; }
|
||||
return designator.trimmed().toUpper() == this->m_designator;
|
||||
return designator.trimmed().toUpper() == m_designator;
|
||||
}
|
||||
|
||||
bool CAirlineIcaoCode::matchesVDesignator(const QString &designator) const
|
||||
@@ -122,7 +122,7 @@ namespace BlackMisc
|
||||
bool CAirlineIcaoCode::matchesIataCode(const QString &iata) const
|
||||
{
|
||||
if (iata.isEmpty()) { return false; }
|
||||
return iata.trimmed().toUpper() == this->m_iataCode;
|
||||
return iata.trimmed().toUpper() == m_iataCode;
|
||||
}
|
||||
|
||||
bool CAirlineIcaoCode::matchesDesignatorOrIataCode(const QString &candidate) const
|
||||
@@ -190,34 +190,20 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAirlineDesignator:
|
||||
return CVariant::fromValue(this->m_designator);
|
||||
case IndexIataCode:
|
||||
return CVariant::fromValue(this->m_iataCode);
|
||||
case IndexAirlineCountryIso:
|
||||
return CVariant::fromValue(this->getCountryIso());
|
||||
case IndexAirlineCountry:
|
||||
return this->m_country.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAirlineName:
|
||||
return CVariant::fromValue(this->m_name);
|
||||
case IndexTelephonyDesignator:
|
||||
return CVariant::fromValue(this->m_telephonyDesignator);
|
||||
case IndexIsVirtualAirline:
|
||||
return CVariant::fromValue(this->m_isVa);
|
||||
case IndexIsOperating:
|
||||
return CVariant::fromValue(this->m_isOperating);
|
||||
case IndexIsMilitary:
|
||||
return CVariant::fromValue(this->m_isMilitary);
|
||||
case IndexDesignatorNameCountry:
|
||||
return CVariant::fromValue(this->getDesignatorNameCountry());
|
||||
case IndexGroupDesignator:
|
||||
return CVariant::fromValue(this->getGroupDesignator());
|
||||
case IndexGroupName:
|
||||
return CVariant::fromValue(this->getGroupName());
|
||||
case IndexGroupId:
|
||||
return CVariant::fromValue(this->getGroupId());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexAirlineDesignator: return CVariant::fromValue(m_designator);
|
||||
case IndexIataCode: return CVariant::fromValue(m_iataCode);
|
||||
case IndexAirlineCountryIso: return CVariant::fromValue(this->getCountryIso());
|
||||
case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAirlineName: return CVariant::fromValue(m_name);
|
||||
case IndexTelephonyDesignator: return CVariant::fromValue(m_telephonyDesignator);
|
||||
case IndexIsVirtualAirline: return CVariant::fromValue(m_isVa);
|
||||
case IndexIsOperating: return CVariant::fromValue(m_isOperating);
|
||||
case IndexIsMilitary: return CVariant::fromValue(m_isMilitary);
|
||||
case IndexDesignatorNameCountry: return CVariant::fromValue(this->getDesignatorNameCountry());
|
||||
case IndexGroupDesignator: return CVariant::fromValue(this->getGroupDesignator());
|
||||
case IndexGroupName: return CVariant::fromValue(this->getGroupName());
|
||||
case IndexGroupId: return CVariant::fromValue(this->getGroupId());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,42 +214,18 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAirlineDesignator:
|
||||
this->setDesignator(variant.value<QString>());
|
||||
break;
|
||||
case IndexIataCode:
|
||||
this->setIataCode(variant.value<QString>());
|
||||
break;
|
||||
case IndexAirlineCountry:
|
||||
this->setCountry(variant.value<CCountry>());
|
||||
break;
|
||||
case IndexAirlineName:
|
||||
this->setName(variant.value<QString>());
|
||||
break;
|
||||
case IndexTelephonyDesignator:
|
||||
this->setTelephonyDesignator(variant.value<QString>());
|
||||
break;
|
||||
case IndexIsVirtualAirline:
|
||||
this->setVirtualAirline(variant.toBool());
|
||||
break;
|
||||
case IndexIsOperating:
|
||||
this->setOperating(variant.toBool());
|
||||
break;
|
||||
case IndexIsMilitary:
|
||||
this->setMilitary(variant.toBool());
|
||||
break;
|
||||
case IndexGroupDesignator:
|
||||
this->setGroupDesignator(variant.toQString());
|
||||
break;
|
||||
case IndexGroupName:
|
||||
this->setGroupName(variant.toQString());
|
||||
break;
|
||||
case IndexGroupId:
|
||||
this->setGroupId(variant.toInt());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexAirlineDesignator: this->setDesignator(variant.value<QString>()); break;
|
||||
case IndexIataCode: this->setIataCode(variant.value<QString>()); break;
|
||||
case IndexAirlineCountry: this->setCountry(variant.value<CCountry>()); break;
|
||||
case IndexAirlineName: this->setName(variant.value<QString>()); break;
|
||||
case IndexTelephonyDesignator: this->setTelephonyDesignator(variant.value<QString>()); break;
|
||||
case IndexIsVirtualAirline: this->setVirtualAirline(variant.toBool()); break;
|
||||
case IndexIsOperating: this->setOperating(variant.toBool()); break;
|
||||
case IndexIsMilitary: this->setMilitary(variant.toBool()); break;
|
||||
case IndexGroupDesignator: this->setGroupDesignator(variant.toQString()); break;
|
||||
case IndexGroupName: this->setGroupName(variant.toQString()); break;
|
||||
case IndexGroupId: this->setGroupId(variant.toInt()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,32 +236,19 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAirlineDesignator:
|
||||
return this->m_designator.compare(compareValue.getDesignator());
|
||||
case IndexIataCode:
|
||||
return this->m_iataCode.compare(compareValue.getIataCode());
|
||||
case IndexAirlineCountry:
|
||||
return this->m_country.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCountry());
|
||||
case IndexDesignatorNameCountry:
|
||||
return this->m_country.getName().compare(compareValue.getCountry().getName(), Qt::CaseInsensitive);
|
||||
case IndexAirlineName:
|
||||
return this->m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
case IndexTelephonyDesignator:
|
||||
return this->m_telephonyDesignator.compare(compareValue.getTelephonyDesignator(), Qt::CaseInsensitive);
|
||||
case IndexIsVirtualAirline:
|
||||
return Compare::compare(this->isVirtualAirline(), compareValue.isVirtualAirline());
|
||||
case IndexIsOperating:
|
||||
return Compare::compare(this->isOperating(), compareValue.isOperating());
|
||||
case IndexIsMilitary:
|
||||
return Compare::compare(this->isMilitary(), compareValue.isMilitary());
|
||||
case IndexGroupDesignator:
|
||||
return this->m_groupDesignator.compare(compareValue.getGroupDesignator(), Qt::CaseInsensitive);
|
||||
case IndexGroupName:
|
||||
return this->m_groupName.compare(compareValue.getGroupName(), Qt::CaseInsensitive);
|
||||
case IndexGroupId:
|
||||
return Compare::compare(this->m_groupId, compareValue.getGroupId());
|
||||
default:
|
||||
break;
|
||||
case IndexAirlineDesignator: return m_designator.compare(compareValue.getDesignator());
|
||||
case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode());
|
||||
case IndexAirlineCountry: return m_country.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCountry());
|
||||
case IndexDesignatorNameCountry: return m_country.getName().compare(compareValue.getCountry().getName(), Qt::CaseInsensitive);
|
||||
case IndexAirlineName: return m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
case IndexTelephonyDesignator: return m_telephonyDesignator.compare(compareValue.getTelephonyDesignator(), Qt::CaseInsensitive);
|
||||
case IndexIsVirtualAirline: return Compare::compare(this->isVirtualAirline(), compareValue.isVirtualAirline());
|
||||
case IndexIsOperating: return Compare::compare(this->isOperating(), compareValue.isOperating());
|
||||
case IndexIsMilitary: return Compare::compare(this->isMilitary(), compareValue.isMilitary());
|
||||
case IndexGroupDesignator: return m_groupDesignator.compare(compareValue.getGroupDesignator(), Qt::CaseInsensitive);
|
||||
case IndexGroupName: return m_groupName.compare(compareValue.getGroupName(), Qt::CaseInsensitive);
|
||||
case IndexGroupId: return Compare::compare(m_groupId, compareValue.getGroupId());
|
||||
default: break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No compare function");
|
||||
return 0;
|
||||
@@ -357,16 +306,16 @@ namespace BlackMisc
|
||||
if (callsign.isEmpty()) { return *this; }
|
||||
const QString callsignAirline = callsign.getAirlineSuffix();
|
||||
if (callsignAirline.isEmpty()) { return *this; }
|
||||
if (callsignAirline == this->m_designator) { return *this; }
|
||||
if (callsignAirline == m_designator) { return *this; }
|
||||
|
||||
const CAirlineIcaoCode callsignIcao(callsignAirline);
|
||||
if (this->m_designator.isEmpty()) { return callsignIcao; }
|
||||
if (m_designator.isEmpty()) { return callsignIcao; }
|
||||
|
||||
// here we have 2 possible codes
|
||||
if (callsignIcao.isVirtualAirline())
|
||||
{
|
||||
|
||||
if (callsignIcao.getDesignator().endsWith(this->m_designator))
|
||||
if (callsignIcao.getDesignator().endsWith(m_designator))
|
||||
{
|
||||
// callsign ICAO is virtual airline of myself, this is more accurate
|
||||
return callsignIcao;
|
||||
|
||||
@@ -36,13 +36,13 @@ namespace BlackMisc
|
||||
//! Value object for ICAO classification
|
||||
class BLACKMISC_EXPORT CAirlineIcaoCode :
|
||||
public CValueObject<CAirlineIcaoCode>,
|
||||
public BlackMisc::Db::IDatastoreObjectWithIntegerKey
|
||||
public Db::IDatastoreObjectWithIntegerKey
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexAirlineDesignator = BlackMisc::CPropertyIndex::GlobalIndexCAirlineIcaoCode,
|
||||
IndexAirlineDesignator = CPropertyIndex::GlobalIndexCAirlineIcaoCode,
|
||||
IndexIataCode,
|
||||
IndexAirlineName,
|
||||
IndexAirlineCountryIso,
|
||||
@@ -64,10 +64,10 @@ namespace BlackMisc
|
||||
CAirlineIcaoCode(const QString &airlineDesignator);
|
||||
|
||||
//! Constructor.
|
||||
CAirlineIcaoCode(const QString &airlineDesignator, const QString &airlineName, const BlackMisc::CCountry &country, const QString &telephony, bool virtualAirline, bool operating);
|
||||
CAirlineIcaoCode(const QString &airlineDesignator, const QString &airlineName, const CCountry &country, const QString &telephony, bool virtualAirline, bool operating);
|
||||
|
||||
//! Get airline, e.g. "DLH"
|
||||
const QString &getDesignator() const { return this->m_designator; }
|
||||
const QString &getDesignator() const { return m_designator; }
|
||||
|
||||
//! Get airline, e.g. "DLH", but "VMVA" for virtual airlines
|
||||
const QString getVDesignator() const;
|
||||
@@ -82,37 +82,37 @@ namespace BlackMisc
|
||||
const QString &getIataCode() const { return m_iataCode; }
|
||||
|
||||
//! Set IATA code
|
||||
void setIataCode(const QString &iataCode) { this->m_iataCode = iataCode.trimmed().toUpper(); }
|
||||
void setIataCode(const QString &iataCode) { m_iataCode = iataCode.trimmed().toUpper(); }
|
||||
|
||||
//! Get country, e.g. "FR"
|
||||
const QString &getCountryIso() const { return this->m_country.getIsoCode(); }
|
||||
const QString &getCountryIso() const { return m_country.getIsoCode(); }
|
||||
|
||||
//! Get country, e.g. "FRANCE"
|
||||
const BlackMisc::CCountry &getCountry() const { return this->m_country; }
|
||||
const CCountry &getCountry() const { return m_country; }
|
||||
|
||||
//! Combined string designator, name, country
|
||||
QString getDesignatorNameCountry() const;
|
||||
|
||||
//! Set country
|
||||
void setCountry(const BlackMisc::CCountry &country) { this->m_country = country; }
|
||||
void setCountry(const CCountry &country) { m_country = country; }
|
||||
|
||||
//! Get name, e.g. "Lufthansa"
|
||||
const QString &getName() const { return this->m_name; }
|
||||
const QString &getName() const { return m_name; }
|
||||
|
||||
//! \copydoc BlackMisc::simplifyNameForSearch
|
||||
//! \copydoc simplifyNameForSearch
|
||||
QString getSimplifiedName() const;
|
||||
|
||||
//! Name plus key, e.g. "Lufthansa (3421)"
|
||||
QString getNameWithKey() const;
|
||||
|
||||
//! Set name
|
||||
void setName(const QString &name) { this->m_name = name.trimmed(); }
|
||||
void setName(const QString &name) { m_name = name.trimmed(); }
|
||||
|
||||
//! Telephony designator such as "Speedbird"
|
||||
const QString &getTelephonyDesignator() const { return this->m_telephonyDesignator; }
|
||||
const QString &getTelephonyDesignator() const { return m_telephonyDesignator; }
|
||||
|
||||
//! Telephony designator such as "Speedbird"
|
||||
void setTelephonyDesignator(const QString &telephony) { this->m_telephonyDesignator = telephony.trimmed().toUpper(); }
|
||||
void setTelephonyDesignator(const QString &telephony) { m_telephonyDesignator = telephony.trimmed().toUpper(); }
|
||||
|
||||
//! Group designator
|
||||
const QString &getGroupDesignator() const { return m_groupDesignator; }
|
||||
@@ -181,7 +181,7 @@ namespace BlackMisc
|
||||
bool isContainedInSimplifiedName(const QString &candidate) const;
|
||||
|
||||
//! Telephony designator?
|
||||
bool hasTelephonyDesignator() const { return !this->m_telephonyDesignator.isEmpty(); }
|
||||
bool hasTelephonyDesignator() const { return !m_telephonyDesignator.isEmpty(); }
|
||||
|
||||
//! Has (airline) name?
|
||||
bool hasName() const { return !m_name.isEmpty(); }
|
||||
@@ -198,23 +198,23 @@ namespace BlackMisc
|
||||
//! What is better, the callsign airline code or this code. Return the better one.
|
||||
CAirlineIcaoCode thisOrCallsignCode(const CCallsign &callsign) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon
|
||||
//! \copydoc Mixin::Icon::toIcon
|
||||
CIcon toIcon() const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
//! \copydoc Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAirlineIcaoCode &compareValue) const;
|
||||
|
||||
//! Validate data
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Update missing parts
|
||||
void updateMissingParts(const CAirlineIcaoCode &otherIcaoCode);
|
||||
@@ -250,7 +250,7 @@ namespace BlackMisc
|
||||
QString m_telephonyDesignator; //!< "Speedbird"
|
||||
QString m_groupDesignator; //!< Group designator
|
||||
QString m_groupName; //!< Group name
|
||||
BlackMisc::CCountry m_country; //!< Country
|
||||
CCountry m_country; //!< Country
|
||||
int m_groupId = -1; //!< Group id
|
||||
bool m_isVa = false; //!< virtual airline
|
||||
bool m_isOperating = true; //!< still operating?
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (candidate.isEmpty() || !this->hasCombinedCode()) { return false; }
|
||||
QString c(candidate.trimmed().toUpper());
|
||||
return c == this->m_combinedCode;
|
||||
return c == m_combinedCode;
|
||||
}
|
||||
|
||||
bool CLivery::matchesColors(const CRgbColor &fuselage, const CRgbColor &tail) const
|
||||
@@ -179,13 +179,13 @@ namespace BlackMisc
|
||||
|
||||
bool CLivery::isAirlineLivery() const
|
||||
{
|
||||
return (this->m_airline.hasValidDesignator());
|
||||
return (m_airline.hasValidDesignator());
|
||||
}
|
||||
|
||||
bool CLivery::isAirlineStandardLivery() const
|
||||
{
|
||||
if (isColorLivery()) { return false; }
|
||||
return (this->m_airline.hasValidDesignator() && this->m_combinedCode.endsWith(standardLiveryMarker()));
|
||||
return (m_airline.hasValidDesignator() && m_combinedCode.endsWith(standardLiveryMarker()));
|
||||
}
|
||||
|
||||
bool CLivery::isColorLivery() const
|
||||
@@ -289,23 +289,16 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::propertyByIndex(index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDescription:
|
||||
return CVariant::fromValue(m_description);
|
||||
case IndexAirlineIcaoCode:
|
||||
return m_airline.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexColorFuselage:
|
||||
return this->m_colorFuselage.propertyByIndex(index.copyFrontRemoved());;
|
||||
case IndexColorTail:
|
||||
return this->m_colorTail.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCombinedCode:
|
||||
return CVariant::fromValue(this->m_combinedCode);
|
||||
case IndexIsMilitary:
|
||||
return CVariant::fromValue(this->m_military);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexDescription: return CVariant::fromValue(m_description);
|
||||
case IndexAirlineIcaoCode: return m_airline.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexColorFuselage: return m_colorFuselage.propertyByIndex(index.copyFrontRemoved());;
|
||||
case IndexColorTail: return m_colorTail.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCombinedCode: return CVariant::fromValue(m_combinedCode);
|
||||
case IndexIsMilitary: return CVariant::fromValue(m_military);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,30 +306,16 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CLivery>(); return; }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDescription:
|
||||
this->m_description = variant.toQString(false);
|
||||
break;
|
||||
case IndexAirlineIcaoCode:
|
||||
this->m_airline.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexColorFuselage:
|
||||
this->m_colorFuselage.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexColorTail:
|
||||
this->m_colorTail.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexCombinedCode:
|
||||
this->setCombinedCode(variant.toQString(false));
|
||||
break;
|
||||
case IndexIsMilitary:
|
||||
this->setMilitary(variant.toBool());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexDescription: m_description = variant.toQString(false); break;
|
||||
case IndexAirlineIcaoCode: m_airline.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexColorFuselage: m_colorFuselage.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexColorTail: m_colorTail.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
|
||||
case IndexCombinedCode: this->setCombinedCode(variant.toQString(false)); break;
|
||||
case IndexIsMilitary: this->setMilitary(variant.toBool()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,23 +323,16 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { return this->getCombinedCode().compare(compareValue.getCombinedCode()); }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(index, compareValue);}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDescription:
|
||||
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexAirlineIcaoCode:
|
||||
return this->m_airline.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAirlineIcaoCode());
|
||||
case IndexColorFuselage:
|
||||
return this->m_colorFuselage.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getColorFuselage());
|
||||
case IndexColorTail:
|
||||
return this->m_colorTail.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getColorTail());
|
||||
case IndexCombinedCode:
|
||||
return this->getCombinedCode().compare(compareValue.getCombinedCode());
|
||||
case IndexIsMilitary:
|
||||
return Compare::compare(this->isMilitary(), compareValue.isMilitary());
|
||||
default:
|
||||
break;
|
||||
case IndexDescription: return m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexAirlineIcaoCode: return m_airline.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAirlineIcaoCode());
|
||||
case IndexColorFuselage: return m_colorFuselage.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getColorFuselage());
|
||||
case IndexColorTail: return m_colorTail.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getColorTail());
|
||||
case IndexCombinedCode: return this->getCombinedCode().compare(compareValue.getCombinedCode());
|
||||
case IndexIsMilitary: return Compare::compare(this->isMilitary(), compareValue.isMilitary());
|
||||
default: break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No compare function");
|
||||
return 0;
|
||||
@@ -378,12 +350,12 @@ namespace BlackMisc
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->m_colorFuselage.isValid()) { this->setColorFuselage(otherLivery.getColorFuselage()); }
|
||||
if (!this->m_colorTail.isValid()) { this->setColorTail(otherLivery.getColorTail()); }
|
||||
if (this->m_combinedCode.isEmpty()) { this->setCombinedCode(otherLivery.getCombinedCode());}
|
||||
if (this->m_description.isEmpty()) { this->setDescription(otherLivery.getDescription());}
|
||||
if (!m_colorFuselage.isValid()) { this->setColorFuselage(otherLivery.getColorFuselage()); }
|
||||
if (!m_colorTail.isValid()) { this->setColorTail(otherLivery.getColorTail()); }
|
||||
if (m_combinedCode.isEmpty()) { this->setCombinedCode(otherLivery.getCombinedCode());}
|
||||
if (m_description.isEmpty()) { this->setDescription(otherLivery.getDescription());}
|
||||
|
||||
this->m_airline.updateMissingParts(otherLivery.getAirlineIcaoCode());
|
||||
m_airline.updateMissingParts(otherLivery.getAirlineIcaoCode());
|
||||
if (!this->hasValidDbKey())
|
||||
{
|
||||
this->setDbKey(otherLivery.getDbKey());
|
||||
@@ -415,9 +387,9 @@ namespace BlackMisc
|
||||
|
||||
// max. 0..35 so far
|
||||
if (score == 0) { return 0; }
|
||||
if (this->isAirlineStandardLivery() && !preferColorLiveries) { score += 10; }
|
||||
|
||||
// overrate non airline liveries / color liveries
|
||||
if (this->isAirlineStandardLivery() && !preferColorLiveries) { score += 10; }
|
||||
if (preferColorLiveries)
|
||||
{
|
||||
if (this->isColorLivery() || !this->hasValidAirlineDesignator())
|
||||
|
||||
@@ -33,13 +33,13 @@ namespace BlackMisc
|
||||
//! Value object encapsulating information about an airpot.
|
||||
class BLACKMISC_EXPORT CLivery :
|
||||
public CValueObject<CLivery>,
|
||||
public BlackMisc::Db::IDatastoreObjectWithIntegerKey
|
||||
public Db::IDatastoreObjectWithIntegerKey
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexDescription = BlackMisc::CPropertyIndex::GlobalIndexCLivery,
|
||||
IndexDescription = CPropertyIndex::GlobalIndexCLivery,
|
||||
IndexAirlineIcaoCode,
|
||||
IndexCombinedCode,
|
||||
IndexColorFuselage,
|
||||
@@ -57,13 +57,13 @@ namespace BlackMisc
|
||||
CLivery(const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const QString &colorFuselage, const QString &colorTail, bool isMilitary);
|
||||
|
||||
//! Constructor
|
||||
CLivery(const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const BlackMisc::CRgbColor &colorFuselage, const BlackMisc::CRgbColor &colorTail, bool isMilitary);
|
||||
CLivery(const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const CRgbColor &colorFuselage, const CRgbColor &colorTail, bool isMilitary);
|
||||
|
||||
//! Constructor
|
||||
CLivery(int dbKey, const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const QString &colorFuselage, const QString &colorTail, bool isMilitary);
|
||||
|
||||
//! Constructor
|
||||
CLivery(int dbKey, const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const BlackMisc::CRgbColor &colorFuselage, const BlackMisc::CRgbColor &colorTail, bool isMilitary);
|
||||
CLivery(int dbKey, const QString &combinedCode, const CAirlineIcaoCode &airline, const QString &description, const CRgbColor &colorFuselage, const CRgbColor &colorTail, bool isMilitary);
|
||||
|
||||
//! Corresponding airline, if any
|
||||
const CAirlineIcaoCode &getAirlineIcaoCode() const { return m_airline; }
|
||||
@@ -90,10 +90,10 @@ namespace BlackMisc
|
||||
bool isContainedInSimplifiedAirlineName(const QString &candidate) const;
|
||||
|
||||
//! Get fuselage color.
|
||||
const BlackMisc::CRgbColor &getColorFuselage() const { return m_colorFuselage; }
|
||||
const CRgbColor &getColorFuselage() const { return m_colorFuselage; }
|
||||
|
||||
//! Get tail color.
|
||||
const BlackMisc::CRgbColor &getColorTail() const { return m_colorTail; }
|
||||
const CRgbColor &getColorTail() const { return m_colorTail; }
|
||||
|
||||
//! Military livery
|
||||
bool isMilitary() const { return m_military; }
|
||||
@@ -105,10 +105,10 @@ namespace BlackMisc
|
||||
void setCombinedCode(const QString &code) { m_combinedCode = code.trimmed().toUpper(); }
|
||||
|
||||
//! Set fuselage color
|
||||
void setColorFuselage(const BlackMisc::CRgbColor &color) { this->m_colorFuselage = color; }
|
||||
void setColorFuselage(const CRgbColor &color) { m_colorFuselage = color; }
|
||||
|
||||
//! Set tail color
|
||||
void setColorTail(const BlackMisc::CRgbColor &color) { this->m_colorTail = color; }
|
||||
void setColorTail(const CRgbColor &color) { m_colorTail = color; }
|
||||
|
||||
//! Fuselage color set?
|
||||
bool hasColorFuselage() const;
|
||||
@@ -120,34 +120,34 @@ namespace BlackMisc
|
||||
bool hasValidColors() const;
|
||||
|
||||
//! Set description
|
||||
void setDescription(const QString &description) { this->m_description = description; }
|
||||
void setDescription(const QString &description) { m_description = description; }
|
||||
|
||||
//! Military aircraft?
|
||||
void setMilitary(bool isMilitary) { this->m_military = isMilitary; }
|
||||
void setMilitary(bool isMilitary) { m_military = isMilitary; }
|
||||
|
||||
//! Matches combined code
|
||||
bool matchesCombinedCode(const QString &candidate) const;
|
||||
|
||||
//! Matches colors
|
||||
bool matchesColors(const BlackMisc::CRgbColor &fuselage, const BlackMisc::CRgbColor &tail) const;
|
||||
bool matchesColors(const CRgbColor &fuselage, const CRgbColor &tail) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
//! \copydoc Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CLivery &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Complete data?
|
||||
bool hasCompleteData() const;
|
||||
|
||||
//! Validate data
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
//! Airline available?
|
||||
bool hasValidAirlineDesignator() const;
|
||||
@@ -168,7 +168,7 @@ namespace BlackMisc
|
||||
double getColorDistance(const CLivery &otherLivery) const;
|
||||
|
||||
//! Combined color distance (fuselage/tail): 0..1 (0 is best)
|
||||
double getColorDistance(const BlackMisc::CRgbColor &fuselage, const BlackMisc::CRgbColor &tail) const;
|
||||
double getColorDistance(const CRgbColor &fuselage, const CRgbColor &tail) const;
|
||||
|
||||
//! Update missing parts
|
||||
void updateMissingParts(const CLivery &otherLivery);
|
||||
@@ -190,7 +190,7 @@ namespace BlackMisc
|
||||
static const QString &standardLiveryMarker();
|
||||
|
||||
//! Standard code for
|
||||
static QString getStandardCode(const BlackMisc::Aviation::CAirlineIcaoCode &airline);
|
||||
static QString getStandardCode(const Aviation::CAirlineIcaoCode &airline);
|
||||
|
||||
//! Color livery marker
|
||||
static const QString &colorLiveryMarker();
|
||||
@@ -199,12 +199,12 @@ namespace BlackMisc
|
||||
static const QString &tempLiveryCode();
|
||||
|
||||
private:
|
||||
CAirlineIcaoCode m_airline; //!< corresponding airline, if any
|
||||
QString m_combinedCode; //!< livery code and pseudo airline ICAO code
|
||||
QString m_description; //!< describes the livery
|
||||
BlackMisc::CRgbColor m_colorFuselage; //!< color of fuselage
|
||||
BlackMisc::CRgbColor m_colorTail; //!< color of tail
|
||||
bool m_military = false; //!< military livery?
|
||||
CAirlineIcaoCode m_airline; //!< corresponding airline, if any
|
||||
QString m_combinedCode; //!< livery code and pseudo airline ICAO code
|
||||
QString m_description; //!< describes the livery
|
||||
CRgbColor m_colorFuselage; //!< color of fuselage
|
||||
CRgbColor m_colorTail; //!< color of tail
|
||||
bool m_military = false; //!< military livery?
|
||||
|
||||
BLACK_METACLASS(
|
||||
CLivery,
|
||||
|
||||
Reference in New Issue
Block a user