[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: [PATCH] Request review for KSharedDataCache (Round 2)
From: Michael Pyne <mpyne () kde ! org>
Date: 2010-05-01 0:00:05
Message-ID: 201004302000.12275.mpyne () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
On Thursday, April 29, 2010 21:12:42 Michael Pyne wrote:
> Well that [changeable layout] isn't what *I* wanted, but I see your point
> given that precondition, and it occurs to me that the one having to touch
> my code afterwards may want to change the layout, so I'll move it around
> indeed.
For everyone's information, KSharedDataCache and KImageCache are now in trunk.
I'll give it a day or two for any last minute comments and port KIconLoader
over shortly.
For my Plasma dev friends, I also intend to port Plasma::Theme over to use
KImageCache, using the attached patch. Please let me know if there are
problems with this.
Regards,
- Michael Pyne
["kdelibs-plasma-use_kimagecache.patch" (text/x-patch)]
Index: plasma/theme.cpp
===================================================================
--- plasma/theme.cpp (revision 1118716)
+++ plasma/theme.cpp (working copy)
@@ -36,7 +36,7 @@
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kmanagerselection.h>
-#include <kpixmapcache.h>
+#include <kimagecache.h>
#include <ksharedconfig.h>
#include <kstandarddirs.h>
#include <kwindowsystem.h>
@@ -149,7 +149,7 @@
QString defaultWallpaperSuffix;
int defaultWallpaperWidth;
int defaultWallpaperHeight;
- KPixmapCache *pixmapCache;
+ KImageCache *pixmapCache;
KSharedConfigPtr svgElementsCache;
QHash<QString, QSet<QString> > invalidElements;
QHash<QString, QPixmap> pixmapsToCache;
@@ -176,9 +176,8 @@
bool ThemePrivate::useCache()
{
if (cacheTheme && !pixmapCache) {
- pixmapCache = new KPixmapCache("plasma_theme_" + themeName);
ThemeConfig config;
- pixmapCache->setCacheLimit(config.themeCacheKb());
+ pixmapCache = new KImageCache("plasma_theme_" + themeName, \
config.themeCacheKb() * 1024); }
return cacheTheme;
@@ -232,7 +231,7 @@
void ThemePrivate::discardCache()
{
- KPixmapCache::deleteCache("plasma_theme_" + themeName);
+ KSharedDataCache::deleteCache("plasma_theme_" + themeName);
delete pixmapCache;
pixmapCache = 0;
invalidElements.clear();
@@ -253,7 +252,7 @@
QHashIterator<QString, QPixmap> it(pixmapsToCache);
while (it.hasNext()) {
it.next();
- pixmapCache->insert(idsToCache[it.key()], it.value());
+ pixmapCache->insertPixmap(idsToCache[it.key()], it.value());
}
pixmapsToCache.clear();
@@ -480,7 +479,7 @@
QFileInfo info(f);
- if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
+ if (useCache() && info.lastModified().toTime_t() > \
pixmapCache->lastModifiedTime()) { discardCache();
} else {
QString svgElementsFile = KStandardDirs::locateLocal("cache", \
"plasma-svgelements-" + themeName); @@ -700,7 +699,12 @@
return true;
}
- return d->pixmapCache->find(key, pix);
+ QPixmap temp = d->pixmapCache->findPixmap(key);
+ if(!temp.isNull()) {
+ pix = temp;
+ return true;
+ }
+ return false;
}
return false;
@@ -709,7 +713,7 @@
// BIC FIXME: Should be merged with the other findInCache method above when we break \
BC bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int \
lastModified) {
- if (d->useCache() && lastModified > d->pixmapCache->timestamp()) {
+ if (d->useCache() && lastModified > d->pixmapCache->lastModifiedTime()) {
return false;
}
@@ -719,7 +723,7 @@
void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
{
if (d->useCache()) {
- d->pixmapCache->insert(key, pix);
+ d->pixmapCache->insertPixmap(key, pix);
}
}
@@ -815,7 +819,9 @@
void Theme::setCacheLimit(int kbytes)
{
if (d->useCache()) {
- d->pixmapCache->setCacheLimit(kbytes);
+ ;
+ // Too late for you bub.
+ // d->pixmapCache->setCacheLimit(kbytes);
}
}
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic