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

List:       kde-commits
Subject:    koffice/krita/ui
From:       Cyrille Berger <cyb () lepi ! org>
Date:       2007-07-31 10:17:11
Message-ID: 1185877031.392555.22110.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 694665 by berger:

make the model faster by caching the preview


 M  +8 -4      kis_bookmarked_filter_configurations_model.cc  


--- trunk/koffice/krita/ui/kis_bookmarked_filter_configurations_model.cc \
#694664:694665 @@ -27,6 +27,7 @@
 struct KisBookmarkedFilterConfigurationsModel::Private {
     KisPaintDeviceSP thumb;
     KisFilterSP filter;
+    QHash<int, QImage> previewCache;
 };
 
 KisBookmarkedFilterConfigurationsModel::KisBookmarkedFilterConfigurationsModel(KisPaintDeviceSP \
thumb, KisFilterSP filter) @@ -49,10 +50,13 @@
     }
     if(role == Qt::DecorationRole)
     {
-        QImage pm(100,100, QImage::Format_ARGB32);
-        KisPaintDeviceSP target = new KisPaintDevice(*d->thumb);
-        d->filter->process(target, QRect(0,0,100,100), configuration(index));
-        return target->convertToQImage(0,0.0);
+        if(not d->previewCache.contains(index.row()))
+        {
+            KisPaintDeviceSP target = new KisPaintDevice(*d->thumb);
+            d->filter->process(target, QRect(0,0,100,100), configuration(index));
+            d->previewCache[index.row()] = target->convertToQImage(0,0.0);
+        }
+        return d->previewCache[index.row()];
     } else {
         return KisBookmarkedConfigurationsModel::data(index, role);
     }


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

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