Bug 125766

Summary: Export Albums on DVD
Product: [Applications] digikam Reporter: Marcus Geißler <jumper>
Component: Plugin-Generic-ArchiveAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED UNMAINTAINED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marcus Geißler 2006-04-17 22:05:45 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    I Don't Know
OS:                Linux

There is a problem when exporting Albums on a DVD. If there a Albums with the same name exporting will stop pushing the files to a tmp directory, if you rename the albums with different names the exporting will go correctly!
Comment 1 Angelo Naselli 2006-07-25 14:07:29 UTC
When you say:
>There is a problem when exporting Albums on a DVD

You mean cdarchive plugin or mpeg one?
Which version of kipi-plugins are you using?

(just a note for me: have to check if 
 it can be related to bug #131284)
Comment 2 Angelo Naselli 2006-07-29 20:07:56 UTC
SVN commit 567662 by anaselli:

BUG: 125766

 M  +28 -4     cdarchiving.cpp  
 M  +3 -0      cdarchiving.h  


--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.cpp #567661:567662
@@ -232,7 +232,6 @@
     m_StreamMainPageAlbumPreview = "";
         
     // Get config from setup dialog.
-    
     albumsList = m_configDlg->getSelectedAlbums();
     m_useHTMLInterface = m_configDlg->getUseHTMLInterface();
     m_useAutoRunWin32 = m_configDlg->getUseAutoRunWin32();
@@ -525,13 +524,15 @@
     destURL = MainTPath + QString::fromLatin1("/up.png");
     KIO::file_copy(srcURL, destURL, -1, true, false, false);
 
+    //clear the temporary list for unique names
+    m_collection_name_list.clear();
     for (QValueList<KIPI::ImageCollection>::iterator it = m_albumsList.begin();
          it != m_albumsList.end(); ++it)
     {
         KIPI::ImageCollection album = *it;
         kdDebug( 51000 ) << "HTML Interface for Album: " << album.name() << endl;
 
-        m_AlbumTitle      = webifyFileName(album.name());
+        m_AlbumTitle      = makeFileNameUnique(m_collection_name_list, webifyFileName(album.name())); //webifyFileName(album.name());
         m_AlbumComments   = m_interface->hasFeature(KIPI::AlbumsHaveComments) ?
                             album.comment() : QString();
         m_AlbumCollection = m_interface->hasFeature(KIPI::AlbumsHaveCategory) ?
@@ -1541,8 +1542,12 @@
     if ( HTMLinterfaceFolder.isEmpty() == false )
        AddFolderTreeToK3bXMLProjectFile(HTMLinterfaceFolder, &stream);
 
+    //clear the temporary list for unique names
+    m_collection_name_list.clear();
+
     for (QValueList<KIPI::ImageCollection>::iterator it = m_albumsList.begin();
          !m_cancelled && (it != m_albumsList.end()); ++it)
+
     {
         d = new KIPICDArchivingPlugin::EventData;
         d->action = KIPICDArchivingPlugin::Progress;
@@ -1652,9 +1657,10 @@
    QString Temp;
    QString collection_name;
    if (m_useHTMLInterface)
-    collection_name = webifyFileName(collection.name());
+    collection_name = makeFileNameUnique(m_collection_name_list, webifyFileName(collection.name()));
    else
-    collection_name = collection.name();
+    collection_name = makeFileNameUnique(m_collection_name_list, collection.name());
+   kdDebug( 51000 ) << "num of unique collections: "<<  m_collection_name_list.size() << endl;
 
    Temp = "<directory name=\""
           + EscapeSgmlText(QTextCodec::codecForLocale(), collection_name, true, true)
@@ -1872,6 +1878,24 @@
   return fileName;
 }
 
+/**
+ * Make sure a file name is unique in list
+ */
+QString CDArchiving::makeFileNameUnique(const QStringList& list, QString fileName) {
+  // Make sure the file name is unique
+  QString fileNameBase=fileName;
+  int count=1;
+  while (list.findIndex(fileName)!=-1) {
+    fileName=fileNameBase + "-" + QString::number(count);
+    ++count;
+  };
+  
+  m_collection_name_list += fileName;
+ 
+  return fileName;
+}
+
+
 }  // NameSpace KIPICDArchivingPlugin
 
 #include "cdarchiving.moc"
--- trunk/extragear/libs/kipi-plugins/cdarchiving/cdarchiving.h #567661:567662
@@ -152,6 +152,7 @@
   
   QObject            *m_parent;
   
+  QStringList        m_collection_name_list;
 private:
   
   bool buildHTMLInterface (void);
@@ -203,6 +204,8 @@
   void readSettings(void);
 
   QString webifyFileName(QString fileName);
+  QString makeFileNameUnique(const QStringList& list, QString fileName);
+
 };
 
 }  // NameSpace KIPICDArchivingPlugin