Skip to content

Commit

Permalink
fix: Remove check for share/images
Browse files Browse the repository at this point in the history
  • Loading branch information
ltoenning committed Dec 8, 2024
1 parent 937c2aa commit 3c18558
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 128 deletions.
51 changes: 0 additions & 51 deletions src/misc/aviation/airlineicaocode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
7 changes: 0 additions & 7 deletions src/misc/aviation/airlineicaocode.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace swift::misc::aviation
IndexAirlineName,
IndexAirlineCountryIso,
IndexAirlineCountry,
IndexAirlineIconHTML,
IndexTelephonyDesignator,
IndexGroupId,
IndexGroupName,
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 0 additions & 8 deletions src/misc/icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
17 changes: 0 additions & 17 deletions src/misc/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions src/misc/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
// -------------------------------------------------------------
Expand Down
29 changes: 0 additions & 29 deletions src/misc/swiftdirectories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()); }

Expand Down
9 changes: 0 additions & 9 deletions src/misc/swiftdirectories.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 3c18558

Please sign in to comment.