Implement a cache pixmap for avatars

Review Request #102050 - Created July 22, 2011 and discarded

Dario Freddi
At the moment, each time an avatar is requested, a new pixmap from the image file is created. This is of course more than evil, and this patch aims to fix that. PixmapCache is a proxy to QPixmapCache for handling avatars' pixmaps efficiently. If this patch gets in, from now on every avatar consumer (tooltips, list view, etc) should get his avatar pixmaps through the cache. Of course, in the future, this will be extended to support the most common and most unefficiently handled pixmaps in our code.
Apparently everything still works
David Edmundson
I don't think your premise for doing this isn't entirely true.
When you load a QPixmap from a file, it is automatically added to an implicit QPixmapCache

  1. True, although this was not the case, as pixmaps were loaded straight from a QImage, hence not allowing the caching part to happen. Switching to QPixmap::load all the calls might as well work for this specific case, such an approach would let us cache also custom-painted pixmaps in the future. If we're not planning to do that, simply using ::load would work.
  2. Just checked again, why on earth does the old code do that? You're right, that it's totally wrong and weird.
    I'm not sure I'm comfortable to accept this code into the 0.1 release, as it's quite a large change.
    After that fine, in fact it will be good to have this act as a QDeclarativeImageProvider for some situations too, which from the looks of it would be easy to do from this.
    Discuss on IRC?