commit 5ea3da39d982cf391fd1a4c836d5b34b7e8c7301
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Fri Jun 8 01:08:44 2012 +0200

    upload d'une gallerie de test ok

diff --git a/original.cpp b/original.cpp
index dd49ff5..2a05aef 100644
--- a/original.cpp
+++ b/original.cpp
@@ -584,7 +584,10 @@ void original::ftpCommandFinished(int commandId, bool error)
 
     //on passe au suivant
     if(m_currentFTPFileUpload >= 0 && m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
-        uploadRecursif();
+        if(m_typeUploadRecursif == "PHP")
+            uploadRecursifPHP();
+        else
+            uploadRecursifGallery();
     }
 }
 
@@ -608,16 +611,18 @@ void original::on_btnPHP_clicked()
     m_fileListToUploadIndex.clear();
     m_currentFTPFileUpload = 0;
     parcoursRecursif(dir.absolutePath(),"");
-    qDebug() << m_fileListToUpload;
+    //qDebug() << m_fileListToUpload;
+    m_typeUploadRecursif = "PHP";
+    uploadRecursifPHP();
 }
 
-void original::uploadRecursif()
+void original::uploadRecursifPHP()
 {
     qDebug() << "uploadRecursif : ";
     if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
         QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
         if(fi.isDir()) {
-            QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath() + "/www");
+            QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
             qDebug() << "mkdir : " << ladest;
             m_ftp->mkdir(ladest);
         }
@@ -633,6 +638,28 @@ void original::uploadRecursif()
     }
 }
 
+void original::uploadRecursifGallery()
+{
+    qDebug() << "uploadRecursifGallery : ";
+    if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
+        QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
+        if(fi.isDir()) {
+            QString ladest = ui->leFTPDirectory->text() + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
+            qDebug() << "mkdir : " << ladest;
+            m_ftp->mkdir(ladest);
+        }
+        else {
+            QFile *fic = new QFile(fi.absoluteFilePath());
+            fic->open(QIODevice::ReadOnly);
+            QString ladest = ui->leFTPDirectory->text() + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
+            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
+            m_ftp->put(fic,ladest);
+            fic->close();
+        }
+        m_currentFTPFileUpload++;
+    }
+}
+
 void original::parcoursRecursif(QString rep, QString repertoireServeur)
 {
     qDebug() << "parcoursRecursif : " << rep;
@@ -644,12 +671,25 @@ void original::parcoursRecursif(QString rep, QString repertoireServeur)
         m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur);
         m_fileListToUploadIndex << list.at(i).absoluteFilePath();
         if(list.at(i).isDir()) {
-            parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath() + "/www"));
+            parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"));
         }
     }
 }
 
 void original::on_btnUpload_clicked()
 {
-    uploadRecursif();
+    qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString();
+    QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString());
+    QDir dir(fi.absoluteFilePath());
+    m_fileListToUpload.clear();
+    m_fileListToUploadIndex.clear();
+    m_currentFTPFileUpload = 0;
+    parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0));
+//    qDebug() << m_fileListToUpload;
+    m_typeUploadRecursif = "Gallery";
+
+    QString ladest = ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0);
+    qDebug() << "mkdir : " << ladest;
+    m_ftp->mkdir(ladest);
+//    uploadRecursifGallery();
 }
diff --git a/original.h b/original.h
index 32b0fef..47385f3 100644
--- a/original.h
+++ b/original.h
@@ -73,7 +73,8 @@ private slots:
                                     qint64 totalBytes);
 
     void on_btnPHP_clicked();
-    void uploadRecursif();
+    void uploadRecursifPHP();
+    void uploadRecursifGallery();
     void parcoursRecursif(QString rep, QString repertoireServeur);
 
     void on_btnUpload_clicked();
@@ -84,6 +85,7 @@ private:
     QMenu *m_menu;
     QLabel *m_labelDeposez;
     QString m_currentProjectDir;
+    QString m_typeUploadRecursif;
     QStringList m_fileListToUploadIndex;
     QMap<QString,QString> m_fileListToUpload;
     int m_currentProjectPictureNumber;
diff --git a/original.ui b/original.ui
index 3f0f442..3fe9876 100644
--- a/original.ui
+++ b/original.ui
@@ -74,7 +74,7 @@
       </widget>
       <widget class="QTabWidget" name="tabWidget">
        <property name="currentIndex">
-        <number>2</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="tab_2">
         <attribute name="title">
@@ -263,24 +263,24 @@
            </property>
           </widget>
          </item>
-         <item row="4" column="2">
-          <widget class="QPushButton" name="btnFTPPublish">
+         <item row="4" column="4">
+          <widget class="QPushButton" name="btnUpload">
            <property name="text">
-            <string>Envoyer</string>
+            <string>Upload gallerie en cours</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="3">
-          <widget class="QPushButton" name="btnPHP">
+         <item row="4" column="0">
+          <widget class="QPushButton" name="btnFTPPublish">
            <property name="text">
-            <string>PHP</string>
+            <string>Connexion FTP</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="4">
-          <widget class="QPushButton" name="btnUpload">
+         <item row="4" column="1">
+          <widget class="QPushButton" name="btnPHP">
            <property name="text">
-            <string>Upload</string>
+            <string>Envoyer le code PHP</string>
            </property>
           </widget>
          </item>
