mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
Ref T385, added propertyBy functions for airport ICAO + style
This commit is contained in:
@@ -12,13 +12,7 @@ namespace BlackMisc
|
||||
|
||||
QString CAirportIcaoCode::convertToQString(bool /** i18n **/) const
|
||||
{
|
||||
return this->m_icaoCode;
|
||||
}
|
||||
|
||||
int CAirportIcaoCode::comparePropertyByIndex(const CPropertyIndex &index, const CAirportIcaoCode &compareValue) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return this->m_icaoCode.compare(compareValue.getIcaoCode(), Qt::CaseInsensitive);
|
||||
return m_icaoCode;
|
||||
}
|
||||
|
||||
bool CAirportIcaoCode::hasValidIcaoCode() const
|
||||
@@ -50,5 +44,24 @@ namespace BlackMisc
|
||||
{
|
||||
return (containsChar(icaoCode, [](QChar c) { return c.isDigit(); }));
|
||||
}
|
||||
|
||||
CVariant CAirportIcaoCode::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
void CAirportIcaoCode::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAirportIcaoCode>(); return; }
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
}
|
||||
|
||||
int CAirportIcaoCode::comparePropertyByIndex(const CPropertyIndex &index, const CAirportIcaoCode &compareValue) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return m_icaoCode.compare(compareValue.getIcaoCode(), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -65,7 +65,13 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Compare for index
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAirportIcaoCode &compareValue) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace BlackMisc
|
||||
return newRealName;
|
||||
}
|
||||
|
||||
CVariant CUser::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CUser::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare by index
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CUser &compareValue) const;
|
||||
|
||||
//! This and another user exchange missing data, This user has priority and overrides first.
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace BlackMisc
|
||||
CVariant Index<Derived>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return myself<Derived>(); }
|
||||
const auto i = index.frontCasted<ColumnIndex>();
|
||||
const auto i = index.frontCasted<ColumnIndex>(); // keep that "auto", otherwise I won's compile
|
||||
switch (i)
|
||||
{
|
||||
case IndexIcon: return CVariant::from(derived()->toIcon());
|
||||
|
||||
Reference in New Issue
Block a user