[KimDaBa] patch to allow export by link

Robert Krawitz rlk at alum.mit.edu
Sun Aug 8 14:02:03 CEST 2004


The following patch allows exporting by link, in addition to copying:

diff -ru kimdaba-2004-07-18-noi18n/kimdaba/export.cpp kimdaba-2004-07-18-noi18n.new/kimdaba/export.cpp
--- kimdaba-2004-07-18-noi18n/kimdaba/export.cpp	2004-05-10 07:43:16.000000000 -0400
+++ kimdaba-2004-07-18-noi18n.new/kimdaba/export.cpp	2004-08-07 13:30:59.770259348 -0400
@@ -91,6 +91,7 @@
     _include = new QRadioButton( i18n("Include in .kim file"), grp );
     _manually = new QRadioButton( i18n("Manual copy next to .kim file"), grp );
     _auto = new QRadioButton( i18n("Automatically copy next to .kim file"), grp );
+    _link = new QRadioButton( i18n("Hard link next to .kim file"), grp );
     _manually->setChecked( true );
 
     connect( this, SIGNAL( helpClicked() ), this, SLOT( slotHelp() ) );
@@ -121,6 +122,7 @@
     QWhatsThis::add( _include, txt );
     QWhatsThis::add( _manually, txt );
     QWhatsThis::add( _auto, txt );
+    QWhatsThis::add( _link, txt );
 }
 
 ImageFileLocation ExportConfig::imageFileLocation() const
@@ -129,6 +131,8 @@
         return Inline;
     else if ( _manually->isChecked() )
         return ManualCopy;
+    else if ( _link->isChecked() )
+        return Link;
     else
         return AutoCopy;
 }
@@ -248,6 +252,8 @@
                 _zip->addLocalFile( file, QString::fromLatin1( "Images/" ) + zippedName );
             else if ( _location == AutoCopy )
                 Util::copy( file, _destdir + QString::fromLatin1( "/" ) + zippedName );
+            else if ( _location == Link )
+                Util::make_link( file, _destdir + QString::fromLatin1( "/" ) + zippedName );
             _steps++;
             _progressDialog->setProgress( _steps );
         }
diff -ru kimdaba-2004-07-18-noi18n/kimdaba/export.h kimdaba-2004-07-18-noi18n.new/kimdaba/export.h
--- kimdaba-2004-07-18-noi18n/kimdaba/export.h	2004-04-18 03:01:39.000000000 -0400
+++ kimdaba-2004-07-18-noi18n.new/kimdaba/export.h	2004-08-07 13:30:59.771259250 -0400
@@ -29,7 +29,7 @@
 class KZip;
 class QProgressDialog;
 
-enum ImageFileLocation { Inline, ManualCopy, AutoCopy };
+enum ImageFileLocation { Inline, ManualCopy, AutoCopy, Link };
 
 class Export :public ImageClient {
 
@@ -73,6 +73,7 @@
 private:
     QRadioButton* _include;
     QRadioButton* _manually;
+    QRadioButton* _link;
     QRadioButton* _auto;
 
 protected slots:
diff -ru kimdaba-2004-07-18-noi18n/kimdaba/util.cpp kimdaba-2004-07-18-noi18n.new/kimdaba/util.cpp
--- kimdaba-2004-07-18-noi18n/kimdaba/util.cpp	2004-06-13 11:43:55.000000000 -0400
+++ kimdaba-2004-07-18-noi18n.new/kimdaba/util.cpp	2004-08-07 13:30:59.774258957 -0400
@@ -313,6 +313,14 @@
     return true;
 }
 
+bool Util::make_link( const QString& from, const QString& to )
+{
+  if (link(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 ) );
diff -ru kimdaba-2004-07-18-noi18n/kimdaba/util.h kimdaba-2004-07-18-noi18n.new/kimdaba/util.h
--- kimdaba-2004-07-18-noi18n/kimdaba/util.h	2004-06-13 11:43:56.000000000 -0400
+++ kimdaba-2004-07-18-noi18n.new/kimdaba/util.h	2004-08-07 13:32:41.613291431 -0400
@@ -35,6 +35,7 @@
     static void checkForBackupFile( const QString& fileName );
     static bool ctrlKeyDown();
     static bool copy( const QString& from, const QString& to );
+    static bool make_link( const QString& from, const QString& to );
     static bool runningDemo();
     static void deleteDemo();
     static QString setupDemo();



More information about the KimDaBa mailing list