mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Airline icon as HTML img code
This commit is contained in:
@@ -179,6 +179,26 @@ namespace BlackMisc
|
||||
return CIcon::iconByIndex(CIcons::StandardIconEmpty);
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getIconResourcePath() const
|
||||
{
|
||||
if (this->hasValidDbKey() && CAirlineIcaoCode::iconIds().contains(this->getDbKey()))
|
||||
{
|
||||
static const QString p("airlines/%1_%2.png");
|
||||
const QString n(p.arg(this->getDbKey(), 5, 10, QChar('0')).arg(this->getDesignator()));
|
||||
return CFileUtils::appendFilePaths(CDirectoryUtils::imagesDirectory(), n);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getIconAsHTMLImage() const
|
||||
{
|
||||
if (this->hasValidDbKey() && CAirlineIcaoCode::iconIds().contains(this->getDbKey()))
|
||||
{
|
||||
return u"<img src=\"" % this->getIconResourcePath() % u"\">";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -201,6 +221,7 @@ namespace BlackMisc
|
||||
case IndexAirlineCountryIso: return CVariant::fromValue(this->getCountryIso());
|
||||
case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAirlineName: return CVariant::fromValue(m_name);
|
||||
case IndexAirlineIconHTML: return CVariant::fromValue(this->getIconAsHTMLImage());
|
||||
case IndexTelephonyDesignator: return CVariant::fromValue(m_telephonyDesignator);
|
||||
case IndexIsVirtualAirline: return CVariant::fromValue(m_isVa);
|
||||
case IndexIsOperating: return CVariant::fromValue(m_isOperating);
|
||||
@@ -242,6 +263,7 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAirlineIconHTML:
|
||||
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());
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace BlackMisc
|
||||
IndexAirlineName,
|
||||
IndexAirlineCountryIso,
|
||||
IndexAirlineCountry,
|
||||
IndexAirlineIconHTML,
|
||||
IndexTelephonyDesignator,
|
||||
IndexGroupId,
|
||||
IndexGroupName,
|
||||
@@ -216,6 +217,12 @@ namespace BlackMisc
|
||||
//! \copydoc Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAirlineIcaoCode &compareValue) const;
|
||||
|
||||
//! Get icon resource path
|
||||
QString getIconResourcePath() const;
|
||||
|
||||
//! Icon has HTML img
|
||||
QString getIconAsHTMLImage() const;
|
||||
|
||||
//! Validate data
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user