commit bbebc37b26a8a45f81160a1a8787f658941efccd
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Fri Jun 8 00:48:38 2012 +0200

    upload complet du code de la gallerie ok

diff --git a/original.cpp b/original.cpp
index 3d46f1c..dd49ff5 100644
--- a/original.cpp
+++ b/original.cpp
@@ -522,6 +522,8 @@ void original::addPictureToProject(QString fic)
 
 void original::on_btnFTPPublish_clicked()
 {
+    m_currentFTPFileUpload = -1;
+
     m_ftp = new QFtp(this);
     connect(m_ftp, SIGNAL(commandFinished(int,bool)),
             this, SLOT(ftpCommandFinished(int,bool)));
@@ -548,12 +550,12 @@ void original::on_btnFTPPublish_clicked()
     //On uploade l'album en cours
     //m_ftp->put()
 
-    m_currentFTPFileUpload = 0;
 
 }
 
 void original::ftpCommandFinished(int commandId, bool error)
 {
+    qDebug() << "ftpCommandFinished : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand();
 #ifndef QT_NO_CURSOR
     setCursor(Qt::ArrowCursor);
 #endif
@@ -569,8 +571,6 @@ void original::ftpCommandFinished(int commandId, bool error)
 
     if (m_ftp->currentCommand() == QFtp::Put) {
         qDebug() << "Put ...";
-        //on passe au suivant
-        on_btnPHP_clicked();
     }
 
     if (m_ftp->currentCommand() == QFtp::Get) {
@@ -581,6 +581,11 @@ void original::ftpCommandFinished(int commandId, bool error)
     } else if (m_ftp->currentCommand() == QFtp::List) {
         qDebug() << "List ...";
     }
+
+    //on passe au suivant
+    if(m_currentFTPFileUpload >= 0 && m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
+        uploadRecursif();
+    }
 }
 
 void original::addToList(const QUrlInfo &urlInfo)
@@ -595,18 +600,56 @@ void original::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes)
 
 void original::on_btnPHP_clicked()
 {
+    qDebug() << "on_btnPHP_clicked";
     //On uploade le code php
     m_ftp->cd(ui->leFTPDirectory->text());
     QDir dir(m_baseDir.absolutePath() + "/www");
-    dir.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
-    QFileInfoList list = dir.entryInfoList();
-    if(m_currentFTPFileUpload < list.count()) {
-        qDebug() << "Upload ... " << list.at(m_currentFTPFileUpload).fileName();
-        QFile *fic = new QFile(list.at(m_currentFTPFileUpload).absoluteFilePath());
-        fic->open(QIODevice::ReadOnly);
-        m_ftp->put(fic,list.at(m_currentFTPFileUpload).fileName());
-        fic->close();
+    m_fileListToUpload.clear();
+    m_fileListToUploadIndex.clear();
+    m_currentFTPFileUpload = 0;
+    parcoursRecursif(dir.absolutePath(),"");
+    qDebug() << m_fileListToUpload;
+}
+
+void original::uploadRecursif()
+{
+    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");
+            qDebug() << "mkdir : " << ladest;
+            m_ftp->mkdir(ladest);
+        }
+        else {
+            QFile *fic = new QFile(fi.absoluteFilePath());
+            fic->open(QIODevice::ReadOnly);
+            QString ladest = ui->leFTPDirectory->text() + "/" + 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;
+    QDir dir(rep);
+    dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+    QFileInfoList list = dir.entryInfoList();
+    for(int i = 0; i < list.count(); i++) {
+        qDebug() << "Ajout de ... " << list.at(i).absoluteFilePath();
+        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"));
+        }
+    }
+}
 
+void original::on_btnUpload_clicked()
+{
+    uploadRecursif();
 }
diff --git a/original.h b/original.h
index 92c9324..32b0fef 100644
--- a/original.h
+++ b/original.h
@@ -73,6 +73,10 @@ private slots:
                                     qint64 totalBytes);
 
     void on_btnPHP_clicked();
+    void uploadRecursif();
+    void parcoursRecursif(QString rep, QString repertoireServeur);
+
+    void on_btnUpload_clicked();
 
 private:
     Ui::original *ui;
@@ -80,6 +84,8 @@ private:
     QMenu *m_menu;
     QLabel *m_labelDeposez;
     QString m_currentProjectDir;
+    QStringList m_fileListToUploadIndex;
+    QMap<QString,QString> m_fileListToUpload;
     int m_currentProjectPictureNumber;
     int m_currentFTPFileUpload;
     QFtp *m_ftp;
diff --git a/original.ui b/original.ui
index e3dec93..3f0f442 100644
--- a/original.ui
+++ b/original.ui
@@ -217,7 +217,7 @@
          <item row="0" column="1">
           <widget class="QLineEdit" name="leFTPLogin">
            <property name="text">
-            <string>rober_10820507</string>
+            <string>webopenphoto</string>
            </property>
           </widget>
          </item>
@@ -231,7 +231,7 @@
          <item row="1" column="1">
           <widget class="QLineEdit" name="leFTPPass">
            <property name="text">
-            <string>EedmuOn1</string>
+            <string>MowlUcDyach6</string>
            </property>
           </widget>
          </item>
@@ -245,7 +245,7 @@
          <item row="2" column="1">
           <widget class="QLineEdit" name="leFTPServeur">
            <property name="text">
-            <string>ftp.hebergratuit.com</string>
+            <string>ftpperso.free.fr</string>
            </property>
           </widget>
          </item>
@@ -259,7 +259,7 @@
          <item row="3" column="1">
           <widget class="QLineEdit" name="leFTPDirectory">
            <property name="text">
-            <string>/htdocs/gallery</string>
+            <string>/gallery</string>
            </property>
           </widget>
          </item>
@@ -277,6 +277,13 @@
            </property>
           </widget>
          </item>
+         <item row="4" column="4">
+          <widget class="QPushButton" name="btnUpload">
+           <property name="text">
+            <string>Upload</string>
+           </property>
+          </widget>
+         </item>
         </layout>
        </widget>
       </widget>
