[KimDaBa] Patch (multi-function)

Robert Krawitz rlk at alum.mit.edu
Sat Aug 14 21:20:55 CEST 2004


Sorry about the form of this patch; I made some changes while on
vacation to better handle things for me, and here are the diffs:

1) A new export option to (not) generate thumbnails.

2) Count the generation of the index file in the progress dialog.

3) Make all angular rotations be positive (both in terms of how
   they're handled and how they're printed for generating thumbnail
   files).

4) Allow export by generation of either symlinks or hard links in
   addition to copying (when your disk is almost full because of 17 GB
   of images, that matters).

In general, kimdaba is the only program I've found under Linux that
can handle the number and size of images I'm generating (these are 6
megapixel images, either shot as native jpegs or converted by a script
I use).  On the 5 day vacation I was on I shot about 700 images, and
I now have a total of 4000 images under management.

diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/export.cpp kimdaba-2004-07-18-noi18n/kimdaba/export.cpp
--- kimdaba-2004-07-18-noi18n.new/kimdaba/export.cpp	2004-08-07 13:30:59.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/export.cpp	2004-08-13 09:49:50.528661498 -0400
@@ -54,7 +54,7 @@
         return;
 
     bool ok;
-    Export* exp = new Export( list, zipFile, config._compress->isChecked(), maxSize, config.imageFileLocation(), ok );
+    Export* exp = new Export( list, zipFile, config._compress->isChecked(), maxSize, config.imageFileLocation(), ok, config._generateThumbnails->isChecked());
     delete exp; // It will not return before done - we still need a class to connect slots etc.
 
     if ( ok )
@@ -73,6 +73,11 @@
     _compress = new QCheckBox( i18n("Compress Export File"), top );
     lay1->addWidget( _compress );
 
+    // Generate thumbnails
+    _generateThumbnails = new QCheckBox( i18n("Generate Thumbnails"), top );
+    _generateThumbnails->setChecked(true);
+    lay1->addWidget( _generateThumbnails );
+
     // Enforece max size
     QHBoxLayout* lay2 = new QHBoxLayout( lay1, 6 );
     _enforeMaxSize = new QCheckBox( i18n( "Limit maximum dimension of images to: " ), top, "_enforeMaxSize" );
@@ -102,6 +107,9 @@
                         "if your images are stored in tiff.</p></qt>" );
     QWhatsThis::add( _compress, txt );
 
+    txt = i18n( "<qt><p>Generate thumbnail images</p></qt>" );
+    QWhatsThis::add( _generateThumbnails, txt );
+
     txt = i18n( "<qt><p>With this option you may limit the maximum dimensions (width and height) of your images. "
                 "Doing so will make the resulting export file smaller, but will of course also make the quality "
                 "worse if someone wants to see the exported images with larger dimensions.</p></qt>" );
@@ -143,7 +151,7 @@
 }
 
 
-Export::Export( const ImageInfoList& list, const QString& zipFile, bool compress, int maxSize, ImageFileLocation location, bool& ok )
+Export::Export( const ImageInfoList& list, const QString& zipFile, bool compress, int maxSize, ImageFileLocation location, bool& ok, bool doGenerateThumbnails)
     : _ok( ok ), _maxSize( maxSize ), _location( location )
 {
     ok = true;
@@ -157,9 +165,11 @@
     }
 
     // Create progress dialog
-    int total = list.count(); // number of images *  create the thumbnails
-    if ( location != ManualCopy )
-        total *= 2;  // number of images *  copy images
+    int total = 1;
+    if (location != ManualCopy)
+      total += list.count();
+    if (doGenerateThumbnails)
+      total += list.count();
 
     _steps = 0;
     _progressDialog = new QProgressDialog( QString::null, i18n("Cancel"), total, 0, "progress dialog", true );
@@ -174,18 +184,22 @@
         copyImages( list );
     }
 
-    if ( _ok ) {
+    if ( _ok && doGenerateThumbnails) {
         _copyingFiles = false;
         generateThumbnails( list );
     }
 
     if ( _ok ) {
         // Create the index.xml file
+        _progressDialog->setLabelText(i18n("Creating index file"));
         QCString indexml = createIndexXML( list );
+
         time_t t;
         time(&t);
         _zip->writeFile( QString::fromLatin1( "index.xml" ), QString::null, QString::null, indexml.size()-1,
                          0444, t, t, t, indexml.data() );
+	_steps++;
+	_progressDialog->setProgress( _steps );
 
         _zip->close();
     }
diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/export.h kimdaba-2004-07-18-noi18n/kimdaba/export.h
--- kimdaba-2004-07-18-noi18n.new/kimdaba/export.h	2004-08-07 13:30:59.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/export.h	2004-08-11 10:15:59.000000000 -0400
@@ -36,7 +36,7 @@
 public:
     static void imageExport( const ImageInfoList& list);
     virtual void pixmapLoaded( const QString& fileName, int width, int height, int angle, const QImage& );
-    Export(  const ImageInfoList& list, const QString& zipFile, bool compress, int maxSize, ImageFileLocation, bool& ok );
+    Export(  const ImageInfoList& list, const QString& zipFile, bool compress, int maxSize, ImageFileLocation, bool& ok, bool generateThumbnails );
     static void showUsageDialog();
 
 protected:
@@ -65,6 +65,7 @@
 public:
     ExportConfig();
     QCheckBox* _compress;
+    QCheckBox* _generateThumbnails;
     QCheckBox* _enforeMaxSize;
     QSpinBox* _maxSize;
 
diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/htmlexportdialog.cpp kimdaba-2004-07-18-noi18n/kimdaba/htmlexportdialog.cpp
--- kimdaba-2004-07-18-noi18n.new/kimdaba/htmlexportdialog.cpp	2004-04-19 14:48:09.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/htmlexportdialog.cpp	2004-08-11 09:59:09.000000000 -0400
@@ -264,7 +264,7 @@
     // Generate .kim file
     if ( _generateKimFile->isChecked() ) {
         bool ok;
-        Export* exp = new Export( _list, kimFileName( false ), false, -1, ManualCopy, ok );
+        Export* exp = new Export( _list, kimFileName( false ), false, -1, ManualCopy, ok, true );
         delete exp; // It will not return before done - we still need a class to connect slots etc.
         if ( !ok )
             return false;
diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/imageinfo.cpp kimdaba-2004-07-18-noi18n/kimdaba/imageinfo.cpp
--- kimdaba-2004-07-18-noi18n.new/kimdaba/imageinfo.cpp	2004-07-12 13:59:00.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/imageinfo.cpp	2004-08-13 10:40:50.835745353 -0400
@@ -475,7 +475,7 @@
             else if ( orientation == 3 || orientation == 4 )
                 _angle = 180;
             else if ( orientation == 5 || orientation == 8 )
-                _angle = -90;
+                _angle = 270;
             else if ( orientation == 6 || orientation == 7 )
                 _angle = 90;
         }
diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/util.cpp kimdaba-2004-07-18-noi18n/kimdaba/util.cpp
--- kimdaba-2004-07-18-noi18n.new/kimdaba/util.cpp	2004-08-07 13:30:59.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/util.cpp	2004-08-11 09:49:11.000000000 -0400
@@ -321,6 +321,14 @@
     return true;
 }
 
+bool Util::make_symlink( const QString& from, const QString& to )
+{
+  if (symlink(from.ascii(), to.ascii()) != 0)
+    return false;
+  else
+    return true;
+}
+
 QString Util::readInstalledFile( const QString& fileName )
 {
     QString inFileName = locate( "data", QString::fromLatin1( "kimdaba/%1" ).arg( fileName ) );
@@ -348,6 +356,9 @@
 
 QString Util::getThumbnailFile( const QString& imageFile, int width, int height, int angle ) {
     QFileInfo info( imageFile );
+    while (angle < 0)
+      angle += 360;
+    angle %= 360;
     return info.dirPath() + QString::fromLatin1("/ThumbNails")+
            QString::fromLatin1("/%1x%2-%3-%4")
                                 .arg(width)
diff -ru kimdaba-2004-07-18-noi18n.new/kimdaba/util.h kimdaba-2004-07-18-noi18n/kimdaba/util.h
--- kimdaba-2004-07-18-noi18n.new/kimdaba/util.h	2004-08-07 13:32:41.000000000 -0400
+++ kimdaba-2004-07-18-noi18n/kimdaba/util.h	2004-08-11 09:07:56.000000000 -0400
@@ -36,6 +36,7 @@
     static bool ctrlKeyDown();
     static bool copy( const QString& from, const QString& to );
     static bool make_link( const QString& from, const QString& to );
+    static bool make_symlink( const QString& from, const QString& to );
     static bool runningDemo();
     static void deleteDemo();
     static QString setupDemo();



More information about the KimDaBa mailing list