mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Airline icon as HTML img code
This commit is contained in:
@@ -179,6 +179,26 @@ namespace BlackMisc
|
|||||||
return CIcon::iconByIndex(CIcons::StandardIconEmpty);
|
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
|
QString CAirlineIcaoCode::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
@@ -201,6 +221,7 @@ namespace BlackMisc
|
|||||||
case IndexAirlineCountryIso: return CVariant::fromValue(this->getCountryIso());
|
case IndexAirlineCountryIso: return CVariant::fromValue(this->getCountryIso());
|
||||||
case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
|
case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexAirlineName: return CVariant::fromValue(m_name);
|
case IndexAirlineName: return CVariant::fromValue(m_name);
|
||||||
|
case IndexAirlineIconHTML: return CVariant::fromValue(this->getIconAsHTMLImage());
|
||||||
case IndexTelephonyDesignator: return CVariant::fromValue(m_telephonyDesignator);
|
case IndexTelephonyDesignator: return CVariant::fromValue(m_telephonyDesignator);
|
||||||
case IndexIsVirtualAirline: return CVariant::fromValue(m_isVa);
|
case IndexIsVirtualAirline: return CVariant::fromValue(m_isVa);
|
||||||
case IndexIsOperating: return CVariant::fromValue(m_isOperating);
|
case IndexIsOperating: return CVariant::fromValue(m_isOperating);
|
||||||
@@ -242,6 +263,7 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
|
case IndexAirlineIconHTML:
|
||||||
case IndexAirlineDesignator: return m_designator.compare(compareValue.getDesignator());
|
case IndexAirlineDesignator: return m_designator.compare(compareValue.getDesignator());
|
||||||
case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode());
|
case IndexIataCode: return m_iataCode.compare(compareValue.getIataCode());
|
||||||
case IndexAirlineCountry: return m_country.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCountry());
|
case IndexAirlineCountry: return m_country.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCountry());
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace BlackMisc
|
|||||||
IndexAirlineName,
|
IndexAirlineName,
|
||||||
IndexAirlineCountryIso,
|
IndexAirlineCountryIso,
|
||||||
IndexAirlineCountry,
|
IndexAirlineCountry,
|
||||||
|
IndexAirlineIconHTML,
|
||||||
IndexTelephonyDesignator,
|
IndexTelephonyDesignator,
|
||||||
IndexGroupId,
|
IndexGroupId,
|
||||||
IndexGroupName,
|
IndexGroupName,
|
||||||
@@ -216,6 +217,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc Mixin::Index::comparePropertyByIndex
|
//! \copydoc Mixin::Index::comparePropertyByIndex
|
||||||
int comparePropertyByIndex(const CPropertyIndex &index, const CAirlineIcaoCode &compareValue) const;
|
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
|
//! Validate data
|
||||||
CStatusMessageList validate() const;
|
CStatusMessageList validate() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user