From 9df67b52b8612adef09a5a9aa9f705cf35302291 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 31 Jul 2018 01:20:31 +0800 Subject: [PATCH] Add const to function signature --- src/base/iconprovider.cpp | 4 +--- src/base/iconprovider.h | 5 ++--- src/gui/guiiconprovider.cpp | 10 +++++----- src/gui/guiiconprovider.h | 10 +++++----- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/base/iconprovider.cpp b/src/base/iconprovider.cpp index 2d6004311..9851536e9 100644 --- a/src/base/iconprovider.cpp +++ b/src/base/iconprovider.cpp @@ -29,8 +29,6 @@ #include "iconprovider.h" -#include - IconProvider::IconProvider(QObject *parent) : QObject(parent) { @@ -57,7 +55,7 @@ IconProvider *IconProvider::instance() return m_instance; } -QString IconProvider::getIconPath(const QString &iconId) +QString IconProvider::getIconPath(const QString &iconId) const { return ":/icons/qbt-theme/" + iconId + ".png"; } diff --git a/src/base/iconprovider.h b/src/base/iconprovider.h index 98e204bd9..3bba13361 100644 --- a/src/base/iconprovider.h +++ b/src/base/iconprovider.h @@ -31,8 +31,7 @@ #define ICONPROVIDER_H #include - -class QString; +#include class IconProvider : public QObject { @@ -43,7 +42,7 @@ public: static void freeInstance(); static IconProvider *instance(); - virtual QString getIconPath(const QString &iconId); + virtual QString getIconPath(const QString &iconId) const; protected: explicit IconProvider(QObject *parent = nullptr); diff --git a/src/gui/guiiconprovider.cpp b/src/gui/guiiconprovider.cpp index bfe4a2ee6..4e2e0532c 100644 --- a/src/gui/guiiconprovider.cpp +++ b/src/gui/guiiconprovider.cpp @@ -57,12 +57,12 @@ GuiIconProvider *GuiIconProvider::instance() return static_cast(m_instance); } -QIcon GuiIconProvider::getIcon(const QString &iconId) +QIcon GuiIconProvider::getIcon(const QString &iconId) const { return getIcon(iconId, iconId); } -QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) +QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) const { #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (m_useSystemTheme) { @@ -78,7 +78,7 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) return QIcon(IconProvider::getIconPath(iconId)); } -QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) +QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const { if (countryIsoCode.isEmpty()) return QIcon(); return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg"); @@ -89,7 +89,7 @@ QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) // Otherwise, the UI looks broken if the icon is not available // in the correct size. #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) -QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) +QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) const { // if icon is loaded from SVG format, it already contains all the required sizes and we shall not resize it // In that case it will be available in the following sizes: @@ -120,7 +120,7 @@ QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) } #endif -QString GuiIconProvider::getIconPath(const QString &iconId) +QString GuiIconProvider::getIconPath(const QString &iconId) const { #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (m_useSystemTheme) { diff --git a/src/gui/guiiconprovider.h b/src/gui/guiiconprovider.h index 0acc13f92..4bc0d4e7f 100644 --- a/src/gui/guiiconprovider.h +++ b/src/gui/guiiconprovider.h @@ -43,10 +43,10 @@ public: static void initInstance(); static GuiIconProvider *instance(); - QIcon getIcon(const QString &iconId); - QIcon getIcon(const QString &iconId, const QString &fallback); - QIcon getFlagIcon(const QString &countryIsoCode); - QString getIconPath(const QString &iconId); + QIcon getIcon(const QString &iconId) const; + QIcon getIcon(const QString &iconId, const QString &fallback) const; + QIcon getFlagIcon(const QString &countryIsoCode) const; + QString getIconPath(const QString &iconId) const override; private slots: void configure(); @@ -55,7 +55,7 @@ private: explicit GuiIconProvider(QObject *parent = nullptr); ~GuiIconProvider(); #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) - QIcon generateDifferentSizes(const QIcon &icon); + QIcon generateDifferentSizes(const QIcon &icon) const; bool m_useSystemTheme; #endif