[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/network/kmldonkey/kmldonkey
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2009-05-11 19:46:51
Message-ID: 1242071211.261454.8610.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 966717 by sebsauer:

Fix improper drawing of the availability column. Patch by Markelov Aleksey, thanks \
Markelov! BUG:171862



 M  +10 -13    availability.cpp  


--- trunk/extragear/network/kmldonkey/kmldonkey/availability.cpp #966716:966717
@@ -30,17 +30,14 @@
 #include <klocale.h>
 #include <kdebug.h>
 #include <qpainter.h>
-#include <q3cache.h>
+#include <QPixmapCache>
 #include <qimage.h>
 #include <QPaintEvent>
 
-static Q3Cache<QImage> pieceCache;
 static int hits = 0;
 
 AvailabilityRenderer::AvailabilityRenderer(int file)
 {
-    pieceCache.setAutoDelete(true);
-    pieceCache.setMaxCost(2048);
     rfileno = file;
     updateFileInfo();
     isClientRenderer = false;
@@ -74,20 +71,20 @@
 void AvailabilityRenderer::paintSection(QPainter& p, QRect& r, QColor& c, int depth, \
bool isTop)  {
     QString cacheKey = \
QString("%1:%2:%3:%4:%5").arg(r.width()).arg(r.height()).arg(depth).arg(isTop).arg(c.name());
                
-    QImage* img = pieceCache.find(cacheKey);
-    if (!img) {
+    QPixmap pm;
+    if (! QPixmapCache::find(cacheKey,pm)) {
         QColor d(c.dark(depth));
-        img = new QImage(r.size(), QImage::Format_ARGB32_Premultiplied);
-        QPainter p(img);
+        pm = QPixmap(r.size());
+        QPainter p(&pm);
         p.setPen(Qt::NoPen);
-        QLinearGradient gradient(0, 0, 0, img->height());
+        QLinearGradient gradient(0, 0, 0, pm.height());
         gradient.setColorAt(0.0, isTop ? d : c);
         gradient.setColorAt(1.0, isTop ? c : d);
-        p.drawRect(img->rect());
-        p.end();
-        pieceCache.insert(cacheKey, img);
+        p.setBrush(gradient);
+        p.drawRect(pm.rect());
+        QPixmapCache::insert(cacheKey, pm);
     } else hits++;
-    p.drawImage(r, *img);
+    p.drawPixmap(r, pm);
 }
 
 void AvailabilityRenderer::paintChunk(QPainter& p, QRect& r, int chunk)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic