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

List:       kde-commits
Subject:    KDE/kdegames/kpat/libkcardgame
From:       Parker Coates <parker.coates () kdemail ! net>
Date:       2010-09-03 21:39:21
Message-ID: 20100903213921.00B86AC884 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1171459 by coates:

Port KCardThemeWidget to KImageCache.

 M  +19 -13    kcardthemewidget.cpp  
 M  +1 -1      kcardthemewidget_p.h  


--- trunk/KDE/kdegames/kpat/libkcardgame/kcardthemewidget.cpp #1171458:1171459
@@ -19,17 +19,20 @@
 #include "kcardthemewidget.h"
 #include "kcardthemewidget_p.h"
 
+#include "common.h"
+
 #include <KConfigDialog>
 #include <KDebug>
 #include <KLineEdit>
 #include <KLocale>
 #include <KGlobal>
-#include <KPixmapCache>
+#include <KImageCache>
 #include <KPushButton>
 #include <KStandardDirs>
 #include <knewstuff3/downloaddialog.h>
 
 #include <QtCore/QMutexLocker>
+#include <QtCore/QScopedPointer>
 #include <QtGui/QApplication>
 #include <QtGui/QFontMetrics>
 #include <QtGui/QListView>
@@ -39,6 +42,12 @@
 #include <QtSvg/QSvgRenderer>
 
 
+namespace
+{
+    const QString previewKeyTemplate( "preview_%1" );
+}
+
+
 PreviewThread::PreviewThread( const KCardThemeWidgetPrivate * d, const QList<KCardTheme> & themes )
   : d( d ),
     m_themes( themes ),
@@ -140,15 +149,10 @@
         if ( !theme.isValid() )
             continue;
 
-        KPixmapCache cache( QString( "kdegames-cards_%1" ).arg( theme.dirName() ) );
-        if ( cache.timestamp() < theme.lastModified().toTime_t() )
-        {
-            cache.discard();
-            cache.setTimestamp( theme.lastModified().toTime_t() );
-        }
-
+        QScopedPointer<KImageCache> cache( createCache( theme ) );
         QPixmap * pix = new QPixmap();
-        if ( cache.find( "preview_" + d->previewString, *pix ) )
+        QString key = previewKeyTemplate.arg( d->previewString );
+        if ( cache->findPixmap( key, pix ) )
         {
             m_previews.insert( theme.displayName(), pix );
         }
@@ -158,6 +162,7 @@
             m_previews.insert( theme.displayName(), 0 );
             previewsNeeded << theme;
         }
+
         m_themes.insert( theme.displayName(), theme );
     }
 
@@ -185,13 +190,14 @@
 }
 
 
-void CardThemeModel::submitPreview( const KCardTheme & theme, const QImage & img )
+void CardThemeModel::submitPreview( const KCardTheme & theme, const QImage & image )
 {
-    KPixmapCache cache( QString( "kdegames-cards_%1" ).arg( theme.dirName() ) );
+    QScopedPointer<KImageCache> cache( createCache( theme ) );
 
-    QPixmap * pix = new QPixmap( QPixmap::fromImage( img ) );
+    QPixmap * pix = new QPixmap( QPixmap::fromImage( image ) );
 
-    cache.insert( "preview_" + d->previewString, *pix );
+    QString key = previewKeyTemplate.arg( d->previewString );
+    cache->insertPixmap( key, *pix );
 
     delete m_previews.value( theme.displayName(), 0 );
     m_previews.insert( theme.displayName(), pix );
--- trunk/KDE/kdegames/kpat/libkcardgame/kcardthemewidget_p.h #1171458:1171459
@@ -73,7 +73,7 @@
 
 private Q_SLOTS:
     void deleteThread();
-    void submitPreview( const KCardTheme & theme, const QImage & img );
+    void submitPreview( const KCardTheme & theme, const QImage & image );
 
 private:
     const KCardThemeWidgetPrivate * const d;
[prev in list] [next in list] [prev in thread] [next in thread] 

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