how to use the cache-to-disk feature in Wallpaper

Benoit Jacob jacob.benoit.1 at gmail.com
Sat Apr 11 03:18:20 CEST 2009


Update:

I hadn't seen revision 952060... very useful detail indeed!

So there's no need for removeFromCache.

Thanks,
Benoit

2009/4/11 Benoit Jacob <jacob.benoit.1 at gmail.com>:
> 2009/4/10 Aaron J. Seigo <aseigo at kde.org>:
>> On Friday 10 April 2009, Benoit Jacob wrote:
>>> I did setUsingDiskCache(true); in the constructor, and I emit
>>
>> when you are ready to cache the image, you can now call:
>>
>> insertIntoCache(const QString& key, const QImage &image);
>>
>> and if you want to see if it exists and retrieve it call:
>>
>> bool findInCache(const QString &key, QImage &image, unsigned int lastModified
>> = 0)
>>
>> with the same key. so in your case, you may want to include things like the
>> the view point and zoom level in the key.
>
> Thanks! I see.
>
>>
>> also, i'd suggest:
>>
>> * deleting the old image so the user doesn't end up with a bajillion cached
>> papers (maybe i should add that bookkeeping into Wallpaper itself? Hmmmm..
>> yes, probably... "let me get back to you on that one," he says, again.)
>
> Maybe I don't understand, but I think that the Wallpaper class doesn't
> seem to have enough information to do the bookkeeping.
>
> Here's an example: the user has 2 different Mandelbrot's in 2
> desktops. The expected behavior is to keep the most recent cached
> image for each Mandelbrot. I don't see how to make that automatically
> handled in Wallpaper?
>
> So unless you can figure a way to make that work magically, I'd suggest either
>
> void removeFromCache(const QString& key);
>
> or changing  insertIntoCache as follows:
>
> void insertIntoCache(const QString& key, const QImage &image, const
> QString& oldkey);
> where the cache entry corresponding to oldkey is automatically removed
> from cache (one may then pass an empty string -- perhaps that'd be the
> default value -- if one doesn't want to remove anything).
>
> Cheers,
> Benoit
>


More information about the Plasma-devel mailing list