mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
fix: Remove check for share/images
This commit is contained in:
@@ -161,26 +161,6 @@ namespace swift::misc::aviation
|
||||
return 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(CSwiftDirectories::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);
|
||||
@@ -205,7 +185,6 @@ namespace swift::misc::aviation
|
||||
case IndexAirlineCountryIso: return QVariant::fromValue(this->getCountryIso());
|
||||
case IndexAirlineCountry: return m_country.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexAirlineName: return QVariant::fromValue(m_name);
|
||||
case IndexAirlineIconHTML: return QVariant::fromValue(this->getIconAsHTMLImage());
|
||||
case IndexTelephonyDesignator: return QVariant::fromValue(m_telephonyDesignator);
|
||||
case IndexIsVirtualAirline: return QVariant::fromValue(m_isVa);
|
||||
case IndexIsOperating: return QVariant::fromValue(m_isOperating);
|
||||
@@ -258,7 +237,6 @@ namespace swift::misc::aviation
|
||||
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:
|
||||
@@ -496,33 +474,4 @@ namespace swift::misc::aviation
|
||||
code.setKeyVersionTimestampFromDatabaseJson(json, prefix);
|
||||
return code;
|
||||
}
|
||||
|
||||
//! \private
|
||||
QSet<int> iconIdsImpl()
|
||||
{
|
||||
QDir dir(CSwiftDirectories::imagesAirlinesDirectory());
|
||||
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "image directory missing");
|
||||
|
||||
CSetBuilder<int> ids;
|
||||
dir.setFilter(QDir::Files | QDir::NoSymLinks);
|
||||
dir.setSorting(QDir::Name);
|
||||
for (const QFileInfo &fileInfo : dir.entryInfoList())
|
||||
{
|
||||
const QString fn(fileInfo.fileName());
|
||||
bool ok = fn.size() > 5;
|
||||
if (!ok) { continue; }
|
||||
SWIFT_VERIFY_X(ok, Q_FUNC_INFO, "wrong file name");
|
||||
const int id = QStringView { fn }.left(5).toInt(&ok);
|
||||
SWIFT_VERIFY_X(ok, Q_FUNC_INFO, "wrong id format");
|
||||
if (!ok) { continue; }
|
||||
ids.insert(id);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
const QSet<int> &CAirlineIcaoCode::iconIds()
|
||||
{
|
||||
static const QSet<int> ids = iconIdsImpl();
|
||||
return ids;
|
||||
}
|
||||
} // namespace swift::misc::aviation
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace swift::misc::aviation
|
||||
IndexAirlineName,
|
||||
IndexAirlineCountryIso,
|
||||
IndexAirlineCountry,
|
||||
IndexAirlineIconHTML,
|
||||
IndexTelephonyDesignator,
|
||||
IndexGroupId,
|
||||
IndexGroupName,
|
||||
@@ -217,12 +216,6 @@ namespace swift::misc::aviation
|
||||
//! \copydoc mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(CPropertyIndexRef index, const CAirlineIcaoCode &compareValue) const;
|
||||
|
||||
//! Get icon resource path
|
||||
QString getIconResourcePath() const;
|
||||
|
||||
//! Icon has HTML img
|
||||
QString getIconAsHTMLImage() const;
|
||||
|
||||
//! Validate data
|
||||
CStatusMessageList validate() const;
|
||||
|
||||
|
||||
@@ -21,14 +21,6 @@ namespace swift::misc
|
||||
// m_index(CIcons::IconIsGenerated), m_descriptiveText(descriptiveText), m_pixmap(pixmap)
|
||||
//{ }
|
||||
|
||||
// CIcon::CIcon(const QString &resourceFilePath, const QString &descriptiveText) :
|
||||
// m_index(CIcons::IconIsFile), m_descriptiveText(descriptiveText)
|
||||
//{
|
||||
// QString fullPath;
|
||||
// m_pixmap = CIcons::pixmapByResourceFileName(QDir::cleanPath(resourceFilePath), fullPath);
|
||||
// m_fileResourcePath = fullPath;
|
||||
// }
|
||||
|
||||
CIcons::IconIndex CIcon::getIndex() const { return m_index; }
|
||||
|
||||
bool CIcon::isIndexBased() const { return m_index < CIcons::IconIsGenerated; }
|
||||
|
||||
@@ -1096,23 +1096,6 @@ namespace swift::misc
|
||||
return rotate(rotateDegrees, pixmapByIndex(index));
|
||||
}
|
||||
|
||||
const QPixmap &CIcons::pixmapByResourceFileName(const QString &relativeFileName, QString &fullFilePath)
|
||||
{
|
||||
//! \fixme KB 20170701 noticed the "cache" is not threadsafe. However, there has never be an issue so far. Added
|
||||
//! thread assert.
|
||||
Q_ASSERT_X(!relativeFileName.isEmpty(), Q_FUNC_INFO, "missing filename");
|
||||
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "not thread safe");
|
||||
|
||||
fullFilePath = CFileUtils::appendFilePaths(CSwiftDirectories::imagesDirectory(), relativeFileName);
|
||||
if (!getResourceFileCache().contains(relativeFileName))
|
||||
{
|
||||
QPixmap pm;
|
||||
const bool s = pm.load(fullFilePath);
|
||||
CIcons::getResourceFileCache().insert(relativeFileName, s ? pm : CIcons::empty());
|
||||
}
|
||||
return CIcons::getResourceFileCache()[relativeFileName];
|
||||
}
|
||||
|
||||
QImage CIcons::changeImageBackgroundColor(const QImage &imgSource, Qt::GlobalColor backgroundColor)
|
||||
{
|
||||
QImage destBackgroundImg(imgSource.size(), QImage::Format_RGB32);
|
||||
|
||||
@@ -691,13 +691,6 @@ namespace swift::misc
|
||||
//! Pixmap by given index rotated
|
||||
static QPixmap pixmapByIndex(IconIndex index, int rotateDegrees);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// By file from swift resource directory
|
||||
// -------------------------------------------------------------
|
||||
|
||||
//! Pixmap by given index
|
||||
static const QPixmap &pixmapByResourceFileName(const QString &relativeFileName, QString &fullFilePath);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Utility functions
|
||||
// -------------------------------------------------------------
|
||||
|
||||
@@ -247,32 +247,6 @@ namespace swift::misc
|
||||
return s;
|
||||
}
|
||||
|
||||
QString getImagesDirImpl()
|
||||
{
|
||||
const QString d(CSwiftDirectories::shareDirectory());
|
||||
const QDir dir(QDir::cleanPath(d + QDir::separator() + "images"));
|
||||
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
|
||||
return dir.absolutePath();
|
||||
}
|
||||
|
||||
const QString &CSwiftDirectories::imagesDirectory()
|
||||
{
|
||||
static const QString s(getImagesDirImpl());
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSwiftDirectories::imagesAirlinesDirectory()
|
||||
{
|
||||
static const QString s(QDir::cleanPath(imagesDirectory() + QDir::separator() + "airlines"));
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSwiftDirectories::imagesFlagsDirectory()
|
||||
{
|
||||
static const QString s(QDir::cleanPath(imagesDirectory() + QDir::separator() + "flags"));
|
||||
return s;
|
||||
}
|
||||
|
||||
QString getHtmlDirImpl()
|
||||
{
|
||||
const QString d(CSwiftDirectories::shareDirectory());
|
||||
@@ -368,9 +342,6 @@ namespace swift::misc
|
||||
QDir d(binDirectory());
|
||||
if (!d.isReadable()) { failed.append(d.absolutePath()); }
|
||||
|
||||
d = QDir(imagesDirectory());
|
||||
if (!d.isReadable()) { failed.append(d.absolutePath()); }
|
||||
|
||||
d = QDir(stylesheetsDirectory());
|
||||
if (!d.isReadable()) { failed.append(d.absolutePath()); }
|
||||
|
||||
|
||||
@@ -86,15 +86,6 @@ namespace swift::misc
|
||||
//! Where qss files are located
|
||||
static const QString &stylesheetsDirectory();
|
||||
|
||||
//! Where images are located
|
||||
static const QString &imagesDirectory();
|
||||
|
||||
//! Where airline images are located
|
||||
static const QString &imagesAirlinesDirectory();
|
||||
|
||||
//! Where flags images are located
|
||||
static const QString &imagesFlagsDirectory();
|
||||
|
||||
//! Where HTML files are located
|
||||
static const QString &htmlDirectory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user