[KimDaBa] A couple more patches

Robert L Krawitz rlk at alum.mit.edu
Fri Jan 7 20:00:08 CET 2005


1) This is the correct fix to handle .thm files (next to .crw files).
   I didn't realize that QString::baseName() strips off the leading
   directory.  I guess when I tested it I ran kimdaba out of the
   directory where the files actually lived.

--- fileinfo.cpp~       2005-01-02 11:04:27.000000000 -0500
+++ fileinfo.cpp        2005-01-07 17:48:37.000000000 -0500
@@ -10,11 +10,12 @@
     fi._fullPath = fileName;
     QString tempFileName( fileName );
     if ( Util::isCRW( fileName ) ) {
+      QString dirName = QFileInfo( fileName ).dirPath();
       QString baseName = QFileInfo( fileName ).baseName();
-      tempFileName = baseName + QString::fromLatin1( ".thm" );
+      tempFileName = dirName + QString::fromLatin1("/") + baseName + QString::fromLatin1( ".thm" );
       QFileInfo tempFile (tempFileName);
       if ( !tempFile.exists() )
-       tempFileName = baseName + QString::fromLatin1( ".THM" );
+       tempFileName = dirName + QString::fromLatin1("/") + baseName + QString::fromLatin1( ".THM" );
     }
 
     KFileMetaInfo metainfo( tempFileName );


2) The first block in this change flushes the thumbnail cache when the
   thumbnail size changes.  This solved a number of redisplay problems
   I was having -- not all of them, but it certainly solved a problem
   I had when I changed the thumbnail size.

   (BTW, why is the cache size of 4K hard coded?)

   The second block (that's currently #ifdef'ed out) may or may not be
   important.  It seems very strange to me to return an empty pixmap
   when it isn't found in cache, but there may be a reason why.

--- thumbnail.cpp~      2005-01-02 15:38:10.000000000 -0500
+++ thumbnail.cpp       2005-01-07 17:14:00.000000000 -0500
@@ -208,7 +208,13 @@
 QPixmapCache& ThumbNail::pixmapCache()
 {
     static QPixmapCache cache;
+    static int lastSize = -1;
     cache.setCacheLimit( 4* 1024 );
+    int currentThumbSize = Options::instance()->thumbSize();
+    if (lastSize != currentThumbSize) {
+      cache.clear();
+      lastSize = currentThumbSize;
+    }
     return cache;
 }
 
@@ -220,7 +226,12 @@
 
     int size = Options::instance()->thumbSize();
     ImageManager::instance()->load( _imageInfo->fileName(),  const_cast<ThumbNail*>( this ), _imageInfo->angle(), size, size, true, false );
-    return emptyPixmap();
+#if 0
+    if ((pix = pixmapCache().find( _imageInfo->fileName())) != NULL)
+      return pix;
+    else
+#endif
+      return emptyPixmap();
 }
 
 QPixmap* ThumbNail::emptyPixmap()



More information about the KimDaBa mailing list