Mark all renderer functions as const as they don't change the object
This commit is contained in:
parent
5c9fe92ff6
commit
9b71eff21b
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
namespace QtForkAwesome {
|
namespace QtForkAwesome {
|
||||||
|
|
||||||
IconEngine::IconEngine(Renderer &renderer)
|
IconEngine::IconEngine(const Renderer &renderer)
|
||||||
: m_renderer(renderer)
|
: m_renderer(renderer)
|
||||||
, m_char(0)
|
, m_char(0)
|
||||||
, m_color()
|
, m_color()
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Renderer;
|
||||||
|
|
||||||
class QT_FORK_AWESOME_ICON_ENGINE_EXPORT IconEngine : public QIconEngine {
|
class QT_FORK_AWESOME_ICON_ENGINE_EXPORT IconEngine : public QIconEngine {
|
||||||
public:
|
public:
|
||||||
IconEngine(Renderer &renderer);
|
IconEngine(const Renderer &renderer);
|
||||||
IconEngine(const IconEngine &other);
|
IconEngine(const IconEngine &other);
|
||||||
~IconEngine() override;
|
~IconEngine() override;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public:
|
||||||
QIconEngine *clone() const override;
|
QIconEngine *clone() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer &m_renderer;
|
const Renderer &m_renderer;
|
||||||
IconBaseType m_char;
|
IconBaseType m_char;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
QIconEngine *create(const QString &filename = QString()) override;
|
QIconEngine *create(const QString &filename = QString()) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer m_renderer;
|
const Renderer m_renderer;
|
||||||
};
|
};
|
||||||
|
|
||||||
QIconEngine *ForkAwesomeIconEnginePlugin::create(const QString &file)
|
QIconEngine *ForkAwesomeIconEnginePlugin::create(const QString &file)
|
||||||
|
|
|
@ -72,7 +72,7 @@ Renderer::operator bool() const
|
||||||
/*!
|
/*!
|
||||||
* \brief Renders the specified \a icon using the specified \a painter.
|
* \brief Renders the specified \a icon using the specified \a painter.
|
||||||
*/
|
*/
|
||||||
void QtForkAwesome::Renderer::render(QChar character, QPainter *painter, const QRect &rect, const QColor &color)
|
void QtForkAwesome::Renderer::render(QChar character, QPainter *painter, const QRect &rect, const QColor &color) const
|
||||||
{
|
{
|
||||||
if (!*this) {
|
if (!*this) {
|
||||||
return;
|
return;
|
||||||
|
@ -89,7 +89,7 @@ void QtForkAwesome::Renderer::render(QChar character, QPainter *painter, const Q
|
||||||
/*!
|
/*!
|
||||||
* \brief Renders the specified \a character as pixmap of the specified \a size.
|
* \brief Renders the specified \a character as pixmap of the specified \a size.
|
||||||
*/
|
*/
|
||||||
QPixmap QtForkAwesome::Renderer::pixmap(QChar icon, const QSize &size, const QColor &color)
|
QPixmap QtForkAwesome::Renderer::pixmap(QChar icon, const QSize &size, const QColor &color) const
|
||||||
{
|
{
|
||||||
const auto scaleFactor =
|
const auto scaleFactor =
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
@ -108,7 +108,7 @@ QPixmap QtForkAwesome::Renderer::pixmap(QChar icon, const QSize &size, const QCo
|
||||||
/*!
|
/*!
|
||||||
* \brief Renders the specified \a icon as pixmap of the specified \a size.
|
* \brief Renders the specified \a icon as pixmap of the specified \a size.
|
||||||
*/
|
*/
|
||||||
QPixmap Renderer::pixmap(Icon icon, const QSize &size, const QColor &color)
|
QPixmap Renderer::pixmap(Icon icon, const QSize &size, const QColor &color) const
|
||||||
{
|
{
|
||||||
return pixmap(QChar(static_cast<IconBaseType>(icon)), size, color);
|
return pixmap(QChar(static_cast<IconBaseType>(icon)), size, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ public:
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
void render(QChar character, QPainter *painter, const QRect &rect, const QColor &color);
|
void render(QChar character, QPainter *painter, const QRect &rect, const QColor &color) const;
|
||||||
void render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color);
|
void render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color) const;
|
||||||
|
|
||||||
QPixmap pixmap(QChar icon, const QSize &size, const QColor &color);
|
QPixmap pixmap(QChar icon, const QSize &size, const QColor &color) const;
|
||||||
QPixmap pixmap(Icon icon, const QSize &size, const QColor &color);
|
QPixmap pixmap(Icon icon, const QSize &size, const QColor &color) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Renderer::InternalData> m_d;
|
std::unique_ptr<Renderer::InternalData> m_d;
|
||||||
|
@ -40,7 +40,7 @@ private:
|
||||||
/*!
|
/*!
|
||||||
* \brief Renders the specified \a icon using the specified \a painter.
|
* \brief Renders the specified \a icon using the specified \a painter.
|
||||||
*/
|
*/
|
||||||
inline void Renderer::render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color)
|
inline void Renderer::render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color) const
|
||||||
{
|
{
|
||||||
render(QChar(static_cast<IconBaseType>(icon)), painter, rect, color);
|
render(QChar(static_cast<IconBaseType>(icon)), painter, rect, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
/// \brief Contains classes provided by the QtForkAwesome library.
|
/// \brief Contains classes provided by the QtForkAwesome library.
|
||||||
namespace QtForkAwesome {
|
namespace QtForkAwesome {
|
||||||
|
|
||||||
QuickImageProvider::QuickImageProvider(Renderer &renderer, const QColor &defaultColor, const QSize &defaultSize, QQuickImageProvider::ImageType type)
|
QuickImageProvider::QuickImageProvider(
|
||||||
|
const Renderer &renderer, const QColor &defaultColor, const QSize &defaultSize, QQuickImageProvider::ImageType type)
|
||||||
: QQuickImageProvider(type)
|
: QQuickImageProvider(type)
|
||||||
, m_renderer(renderer)
|
, m_renderer(renderer)
|
||||||
, m_defaultColor(defaultColor)
|
, m_defaultColor(defaultColor)
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Renderer;
|
||||||
|
|
||||||
class QT_QUICK_FORK_AWESOME_EXPORT QuickImageProvider : public QQuickImageProvider {
|
class QT_QUICK_FORK_AWESOME_EXPORT QuickImageProvider : public QQuickImageProvider {
|
||||||
public:
|
public:
|
||||||
QuickImageProvider(Renderer &renderer, const QColor &defaultColor = QColor(), const QSize &defaultSize = QSize(64, 64),
|
QuickImageProvider(const Renderer &renderer, const QColor &defaultColor = QColor(), const QSize &defaultSize = QSize(64, 64),
|
||||||
QQuickImageProvider::ImageType type = QQuickImageProvider::Pixmap);
|
QQuickImageProvider::ImageType type = QQuickImageProvider::Pixmap);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
|
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
|
||||||
|
@ -27,7 +27,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Renderer &m_renderer;
|
const Renderer &m_renderer;
|
||||||
QColor m_defaultColor;
|
QColor m_defaultColor;
|
||||||
QSize m_defaultSize;
|
QSize m_defaultSize;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue