diff options
-rw-r--r-- | avatar.cpp | 22 | ||||
-rw-r--r-- | avatar.h | 4 |
2 files changed, 13 insertions, 13 deletions
@@ -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 @@ -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); |