From 3c18558f50f6ed6d269f1a520fda6b2cb1d8cf62 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Fri, 6 Dec 2024 18:55:32 +0100 Subject: [PATCH] fix: Remove check for share/images --- src/misc/aviation/airlineicaocode.cpp | 51 --------------------------- src/misc/aviation/airlineicaocode.h | 7 ---- src/misc/icon.cpp | 8 ----- src/misc/icons.cpp | 17 --------- src/misc/icons.h | 7 ---- src/misc/swiftdirectories.cpp | 29 --------------- src/misc/swiftdirectories.h | 9 ----- 7 files changed, 128 deletions(-) diff --git a/src/misc/aviation/airlineicaocode.cpp b/src/misc/aviation/airlineicaocode.cpp index 760644bd9..d54db5f9f 100644 --- a/src/misc/aviation/airlineicaocode.cpp +++ b/src/misc/aviation/airlineicaocode.cpp @@ -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"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(); 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 iconIdsImpl() - { - QDir dir(CSwiftDirectories::imagesAirlinesDirectory()); - Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "image directory missing"); - - CSetBuilder 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 &CAirlineIcaoCode::iconIds() - { - static const QSet ids = iconIdsImpl(); - return ids; - } } // namespace swift::misc::aviation diff --git a/src/misc/aviation/airlineicaocode.h b/src/misc/aviation/airlineicaocode.h index f453072fe..d09f806d9 100644 --- a/src/misc/aviation/airlineicaocode.h +++ b/src/misc/aviation/airlineicaocode.h @@ -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; diff --git a/src/misc/icon.cpp b/src/misc/icon.cpp index 5d2051579..df8ffb810 100644 --- a/src/misc/icon.cpp +++ b/src/misc/icon.cpp @@ -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; } diff --git a/src/misc/icons.cpp b/src/misc/icons.cpp index 573e1220b..fb75f9396 100644 --- a/src/misc/icons.cpp +++ b/src/misc/icons.cpp @@ -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); diff --git a/src/misc/icons.h b/src/misc/icons.h index 256a74003..dc2593f92 100644 --- a/src/misc/icons.h +++ b/src/misc/icons.h @@ -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 // ------------------------------------------------------------- diff --git a/src/misc/swiftdirectories.cpp b/src/misc/swiftdirectories.cpp index 9c9d437be..6b3d1bec8 100644 --- a/src/misc/swiftdirectories.cpp +++ b/src/misc/swiftdirectories.cpp @@ -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()); } diff --git a/src/misc/swiftdirectories.h b/src/misc/swiftdirectories.h index 96ea3624c..d0ff98520 100644 --- a/src/misc/swiftdirectories.h +++ b/src/misc/swiftdirectories.h @@ -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();