aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avatar.cpp22
-rw-r--r--avatar.h4
2 files changed, 13 insertions, 13 deletions
diff --git a/avatar.cpp b/avatar.cpp
index eeb61f30..ee7db6ed 100644
--- a/avatar.cpp
+++ b/avatar.cpp
@@ -30,19 +30,19 @@ class Avatar::Private
{
public:
Private(Connection* c, QIcon di) : _connection(c), _defaultIcon(di) { }
- QImage get(QSize size, Avatar::notifier_t notifier);
+ QImage get(QSize size, Avatar::notifier_t notifier) const;
Connection* _connection;
const QIcon _defaultIcon;
QUrl _url;
- QImage _originalImage;
- std::vector<QPair<QSize, QImage>> _scaledImages;
-
- QSize _requestedSize;
- bool _valid = false;
- MediaThumbnailJob* _ongoingRequest = nullptr;
- std::vector<notifier_t> notifiers;
+ // The below are related to image caching, hence mutable
+ mutable QImage _originalImage;
+ mutable std::vector<QPair<QSize, QImage>> _scaledImages;
+ mutable QSize _requestedSize;
+ mutable bool _valid = false;
+ mutable MediaThumbnailJob* _ongoingRequest = nullptr;
+ mutable std::vector<notifier_t> notifiers;
};
Avatar::Avatar(Connection* connection, QIcon defaultIcon)
@@ -51,17 +51,17 @@ Avatar::Avatar(Connection* connection, QIcon defaultIcon)
Avatar::~Avatar() = default;
-QImage Avatar::get(int dimension, Avatar::notifier_t notifier)
+QImage Avatar::get(int dimension, notifier_t notifier) const
{
return d->get({dimension, dimension}, notifier);
}
-QImage Avatar::get(int width, int height, Avatar::notifier_t notifier)
+QImage Avatar::get(int width, int height, notifier_t notifier) const
{
return d->get({width, height}, notifier);
}
-QImage Avatar::Private::get(QSize size, Avatar::notifier_t notifier)
+QImage Avatar::Private::get(QSize size, Avatar::notifier_t notifier) const
{
// FIXME: Alternating between longer-width and longer-height requests
// is a sure way to trick the below code into constantly getting another
diff --git a/avatar.h b/avatar.h
index bf9cfdcd..28c16e4d 100644
--- a/avatar.h
+++ b/avatar.h
@@ -35,8 +35,8 @@ namespace QMatrixClient
using notifier_t = std::function<void()>;
- QImage get(int dimension, notifier_t notifier);
- QImage get(int w, int h, notifier_t notifier);
+ QImage get(int dimension, notifier_t notifier) const;
+ QImage get(int w, int h, notifier_t notifier) const;
QUrl url() const;
bool updateUrl(const QUrl& newUrl);