13#if defined(KGUIADDONS_LIB) && !defined(KCOREADDONS_LIB)
15#warning "KImageCache requires KF5CoreAddons (for kshareddatacache.h)"
17#pragma message("KImageCache requires KF5CoreAddons (for kshareddatacache.h)")
21#include <klocalimagecacheimpl.h>
22#include <kshareddatacache.h>
27#define KImageCache KSharedPixmapCacheMixin<KSharedDataCache>
74 : T(cacheName, defaultCacheSize, expectedItemSize)
75 , KLocalImageCacheImplementation(defaultCacheSize)
94 insertLocalPixmap(key, pixmap);
116 if (this->insert(key, serializeImage(image))) {
117 updateModifiedTime();
131 bool findPixmap(
const QString &key, QPixmap *destination)
const
133 if (findLocalPixmap(key, destination)) {
137 QByteArray cachedData;
138 if (!this->find(key, &cachedData) || cachedData.isNull()) {
143 destination->loadFromData(cachedData,
"PNG");
146 insertLocalPixmap(key, *destination);
158 bool findImage(
const QString &key, QImage *destination)
const
160 QByteArray cachedData;
161 if (!this->find(key, &cachedData) || cachedData.isNull()) {
166 destination->loadFromData(cachedData,
"PNG");
185 using KLocalImageCacheImplementation::lastModifiedTime;
192 using KLocalImageCacheImplementation::pixmapCaching;
202 using KLocalImageCacheImplementation::setPixmapCaching;
208 using KLocalImageCacheImplementation::pixmapCacheLimit;
216 using KLocalImageCacheImplementation::setPixmapCacheLimit;
A simple wrapping layer over KSharedDataCache to support caching images and pixmaps.
Definition kimagecache.h:58
void clear()
Removes all entries from the cache.
Definition kimagecache.h:176
bool findPixmap(const QString &key, QPixmap *destination) const
Copies the cached pixmap identified by key to destination.
Definition kimagecache.h:131
KSharedPixmapCacheMixin(const QString &cacheName, unsigned defaultCacheSize, unsigned expectedItemSize=0)
Constructs an image cache, named by cacheName, with a default size of defaultCacheSize.
Definition kimagecache.h:73
bool findImage(const QString &key, QImage *destination) const
Copies the cached image identified by key to destination.
Definition kimagecache.h:158
bool insertPixmap(const QString &key, const QPixmap &pixmap)
Inserts the pixmap given by pixmap to the cache, accessible with key.
Definition kimagecache.h:92
bool insertImage(const QString &key, const QImage &image)
Inserts the image into the shared cache, accessible with key.
Definition kimagecache.h:114