Ref T385, added propertyBy functions for airport ICAO + style

This commit is contained in:
Klaus Basan
2018-10-07 15:00:47 +02:00
parent 1280359fe1
commit abe363494b
5 changed files with 30 additions and 11 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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>();

View File

@@ -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.

View File

@@ -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());