commit d8d0edae16fb3c3c6cd434ca8e4d3c827b5a49b4
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Fri Jun 8 19:07:03 2012 +0200

    upload valide sur ftpperso

diff --git a/original.cpp b/original.cpp
index 6993efc..dc56c31 100644
--- a/original.cpp
+++ b/original.cpp
@@ -306,38 +306,8 @@ void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
         }
 
     }
-
-
-    ui->lwPictures->clear();
-    m_currentProjectDir = item->data(1,0).toString();
-    m_currentProjectPictureNumber=0;
-
-    QDir dir(item->data(1,0).toString()+"/thumbs/");
-    dir.setFilter(QDir::Files);
-    dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
-    QFileInfoList list = dir.entryInfoList();
-    for(int i = 0; i < list.count(); i++) {
-        qDebug() << list.at(i).fileName();
-        QListWidgetItem *newitem = new QListWidgetItem();
-        QIcon icone(list.at(i).absoluteFilePath());//pour la mettre  à coté de l'item
-        newitem->setIcon(icone); // ajout de la petite icone sur l'item
-        newitem->setText(list.at(i).fileName());
-        ui->lwPictures->insertItem(i,newitem);
-        m_currentProjectPictureNumber = i;
-    }
-
-    if(m_currentProjectPictureNumber == 0) {
-        qDebug() << "Pas d'image ... message";
-        m_labelDeposez->resize(ui->lwPictures->size());
-        m_labelDeposez->move(ui->lwPictures->pos());
-        m_labelDeposez->show();
-        qDebug() << m_labelDeposez->pos();
-        qDebug() << m_labelDeposez->size();
-    }
-    else {
-        m_labelDeposez->hide();
-    }
-    m_currentProjectPictureNumber++;
+m_currentProjectPictureNumber++;
+    refreshPictureList();
     qDebug() << "On continue la numerotation a " << m_currentProjectPictureNumber;
     qDebug() << "Espace de stockage du projet " << m_currentProjectDir;
 }
@@ -411,6 +381,9 @@ void original::addPictureToProject(QString fic)
     ui->statusBar->showMessage(trUtf8("Fichier en cours: %1").arg(fic),3000);
     qApp->processEvents();
 
+    if(m_currentProjectPictureNumber == 0)
+        m_currentProjectPictureNumber = 1;
+
     qDebug() << "Processing : " << fic;
     QPixmap pixmap(fic);
     pixmap.save(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
@@ -439,88 +412,128 @@ void original::addPictureToProject(QString fic)
     ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta]").arg(fic),3000);
 
     //================== on copie les metadata
-    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fic.toStdString());
-    Exiv2::Image::AutoPtr imageLQ = Exiv2::ImageFactory::open(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
-    Exiv2::Image::AutoPtr imageMQ = Exiv2::ImageFactory::open(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
-    Exiv2::Image::AutoPtr imageHQ = Exiv2::ImageFactory::open(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
-    Exiv2::Image::AutoPtr imageThumb = Exiv2::ImageFactory::open(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
-    if (image.get() != 0)
-    {
-        image->readMetadata();
-        Exiv2::ExifData &exifData = image->exifData();
-        if (!exifData.empty())
+    try {
+        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fic.toStdString());
+        Exiv2::Image::AutoPtr imageLQ = Exiv2::ImageFactory::open(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
+        Exiv2::Image::AutoPtr imageMQ = Exiv2::ImageFactory::open(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
+        Exiv2::Image::AutoPtr imageHQ = Exiv2::ImageFactory::open(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
+        Exiv2::Image::AutoPtr imageThumb = Exiv2::ImageFactory::open(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
+        if (image.get() != 0)
         {
-            bool setArtist = false;
-            bool setCopyright = false;
-            bool setSoftware = false;
-            Exiv2::ExifData::const_iterator end = exifData.end();
-            qDebug() << "============================ DEBUT ===============================";
-            for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
+            image->readMetadata();
+            Exiv2::ExifData &exifData = image->exifData();
+            if (!exifData.empty())
             {
-                qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
-                if (i->key() == "Exif.Image.Artist") {
-                    exifData["Exif.Image.Artist"]    = "Eric S.";
-                    setArtist = true;
-                }
-                if (i->key() == "Exif.Image.Copyright") {
-                    exifData["Exif.Image.Copyright"]    = "Eric S.";
-                    setCopyright = true;
+                bool setArtist = false;
+                bool setCopyright = false;
+                bool setSoftware = false;
+                Exiv2::ExifData::const_iterator end = exifData.end();
+//                qDebug() << "============================ DEBUT ===============================";
+                for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
+                {
+//                    qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
+                    if (i->key() == "Exif.Image.Artist") {
+                        exifData["Exif.Image.Artist"]    = "Eric S.";
+                        setArtist = true;
+                    }
+                    if (i->key() == "Exif.Image.Copyright") {
+                        exifData["Exif.Image.Copyright"]    = "Eric S.";
+                        setCopyright = true;
+                    }
+                    if (i->key() == "Exif.Image.Software") {
+                        exifData["Exif.Image.Software"]  = "RyXeo WebPhotoAlbum - http://www.ryxeo.com/";
+                        setSoftware = true;
+                    }
                 }
-                if (i->key() == "Exif.Image.Software") {
-                    exifData["Exif.Image.Software"]  = "RyXeo WebPhotoAlbum - http://www.ryxeo.com/";
-                    setSoftware = true;
+                //Si on n'a pas les meta il faut les ajouter
+
+                //Mise à jour de l'auteur
+                if(!setArtist) {
+                    Exiv2::ExifKey k("Exif.Image.Artist");
+                    Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
+                    v->read("Eric S.");
+                    exifData.add(k,v.get());
                 }
-            }
-            //Si on n'a pas les meta il faut les ajouter
-
-            //Mise à jour de l'auteur
-            if(!setArtist) {
-                Exiv2::ExifKey k("Exif.Image.Artist");
-                Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
-                v->read("Eric S.");
-                exifData.add(k,v.get());
-            }
 
-            if(!setCopyright) {
-                Exiv2::ExifKey k2("Exif.Image.Copyright");
-                Exiv2::Value::AutoPtr v2 = Exiv2::Value::create(Exiv2::asciiString);
-                v2->read("Eric S.");
-                exifData.add(k2,v2.get());
-            }
+                if(!setCopyright) {
+                    Exiv2::ExifKey k2("Exif.Image.Copyright");
+                    Exiv2::Value::AutoPtr v2 = Exiv2::Value::create(Exiv2::asciiString);
+                    v2->read("Eric S.");
+                    exifData.add(k2,v2.get());
+                }
 
-            if(!setSoftware) {
-                Exiv2::ExifKey k3("Exif.Image.Software");
-                Exiv2::Value::AutoPtr v3 = Exiv2::Value::create(Exiv2::asciiString);
-                v3->read("RyXéo WebPhotoAlbum - http://www.ryxeo.com/");
-                exifData.add(k3,v3.get());
-            }
+                if(!setSoftware) {
+                    Exiv2::ExifKey k3("Exif.Image.Software");
+                    Exiv2::Value::AutoPtr v3 = Exiv2::Value::create(Exiv2::asciiString);
+                    v3->read("RyXéo WebPhotoAlbum - http://www.ryxeo.com/");
+                    exifData.add(k3,v3.get());
+                }
 
-            qDebug() << "============================ APRES ===============================";
-            Exiv2::ExifData::const_iterator end2 = exifData.end();
-            for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
-            {
-                qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
-            }
-            qDebug() << "============================ FIN ===============================";
+//                qDebug() << "============================ APRES ===============================";
+                Exiv2::ExifData::const_iterator end2 = exifData.end();
+//                for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
+//                {
+//                    qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
+//                }
+//                qDebug() << "============================ FIN ===============================";
 
-            imageLQ->setExifData(exifData);
-            imageLQ->writeMetadata();
+                imageLQ->setExifData(exifData);
+                imageLQ->writeMetadata();
 
-            imageMQ->setExifData(exifData);
-            imageMQ->writeMetadata();
+                imageMQ->setExifData(exifData);
+                imageMQ->writeMetadata();
 
-            imageHQ->setExifData(exifData);
-            imageHQ->writeMetadata();
+                imageHQ->setExifData(exifData);
+                imageHQ->writeMetadata();
 
-            imageThumb->setExifData(exifData);
-            imageThumb->writeMetadata();
+                imageThumb->setExifData(exifData);
+                imageThumb->writeMetadata();
+            }
         }
     }
-    m_currentProjectPictureNumber++;
+    catch(...) {
+        qDebug() << "Erreur EXIV2";
+    }
     ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta] ... terminé").arg(fic),3000);
+m_currentProjectPictureNumber++;
+    refreshPictureList();
 }
 
-void original::on_btnFTPPublish_clicked()
+void original::refreshPictureList()
+{
+    QTreeWidgetItem *item = ui->treeWidget->currentItem();
+    ui->lwPictures->clear();
+    m_currentProjectDir = item->data(1,0).toString();
+    int currentProjectPictureNumber=0;
+
+    QDir dir(item->data(1,0).toString()+"/thumbs/");
+    dir.setFilter(QDir::Files);
+    dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
+    QFileInfoList list = dir.entryInfoList();
+    for(int i = 0; i < list.count(); i++) {
+        qDebug() << list.at(i).fileName();
+        QListWidgetItem *newitem = new QListWidgetItem();
+        QIcon icone(list.at(i).absoluteFilePath());//pour la mettre  à coté de l'item
+        newitem->setIcon(icone); // ajout de la petite icone sur l'item
+        newitem->setText(list.at(i).fileName());
+        ui->lwPictures->insertItem(i,newitem);
+        currentProjectPictureNumber = i+1;
+    }
+
+    if(currentProjectPictureNumber == 0) {
+        qDebug() << "Pas d'image ... on affiche le message drag & drop";
+        m_labelDeposez->resize(ui->lwPictures->size());
+        m_labelDeposez->move(ui->lwPictures->pos());
+        m_labelDeposez->show();
+        qDebug() << m_labelDeposez->pos();
+        qDebug() << m_labelDeposez->size();
+    }
+    else {
+        m_labelDeposez->hide();
+    }
+}
+
+void original::ftpConnect()
 {
     m_currentFTPFileUpload = -1;
 
@@ -545,12 +558,8 @@ void original::on_btnFTPPublish_clicked()
     m_ftp->mkdir(ui->leFTPDirectory->text());
     m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries");
 
-
-
     //On uploade l'album en cours
     //m_ftp->put()
-
-
 }
 
 void original::ftpCommandFinished(int commandId, bool error)
@@ -583,12 +592,16 @@ void original::ftpCommandFinished(int commandId, bool error)
     }
 
     //on passe au suivant
-    if(m_currentFTPFileUpload >= 0 && m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
+    if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) {
+        qDebug() << "Il en reste encore a envoyer ";
         if(m_typeUploadRecursif == "PHP")
             uploadRecursifPHP();
         else
             uploadRecursifGallery();
     }
+    else {
+        qDebug() << "Tout a ete expedie ";
+    }
 }
 
 void original::addToList(const QUrlInfo &urlInfo)
@@ -603,6 +616,7 @@ void original::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes)
 
 void original::on_btnPHP_clicked()
 {
+    ftpConnect();
     qDebug() << "on_btnPHP_clicked";
     //On uploade le code php
     m_ftp->cd(ui->leFTPDirectory->text());
@@ -664,7 +678,7 @@ void original::parcoursRecursif(QString rep, QString repertoireServeur)
 {
     qDebug() << "parcoursRecursif : " << rep;
     QDir dir(rep);
-    dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+    dir.setFilter(QDir::Hidden | 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();
@@ -678,6 +692,7 @@ void original::parcoursRecursif(QString rep, QString repertoireServeur)
 
 void original::on_btnUpload_clicked()
 {
+    ftpConnect();
     qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString();
     QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString());
     QDir dir(fi.absoluteFilePath());
diff --git a/original.h b/original.h
index 47385f3..68d5a25 100644
--- a/original.h
+++ b/original.h
@@ -1,5 +1,5 @@
 /**
-  * Classe 
+  * Classe
   * @see https://redmine.ryxeo.com/projects/
   * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
   * @see The GNU Public License (GNU/GPL) v3
@@ -46,11 +46,11 @@ class original;
 class original : public QMainWindow
 {
     Q_OBJECT
-    
+
 public:
     explicit original(QWidget *parent = 0);
     ~original();
-    
+
 private slots:
     void on_action_Nouvel_album_triggered();
     void on_btnSave_clicked();
@@ -60,7 +60,8 @@ private slots:
     void dragEnterEvent(QDragEnterEvent *event);
     void dropEvent(QDropEvent *event);
     void addPictureToProject(QString fic);
-    void on_btnFTPPublish_clicked();
+    void refreshPictureList();
+    void ftpConnect();
 
 //    void connectOrDisconnect();
 //    void uploadFile();
diff --git a/original.ui b/original.ui
index 3fe9876..ff04a26 100644
--- a/original.ui
+++ b/original.ui
@@ -74,7 +74,7 @@
       </widget>
       <widget class="QTabWidget" name="tabWidget">
        <property name="currentIndex">
-        <number>0</number>
+        <number>2</number>
        </property>
        <widget class="QWidget" name="tab_2">
         <attribute name="title">
@@ -233,6 +233,9 @@
            <property name="text">
             <string>MowlUcDyach6</string>
            </property>
+           <property name="echoMode">
+            <enum>QLineEdit::PasswordEchoOnEdit</enum>
+           </property>
           </widget>
          </item>
          <item row="2" column="0">
@@ -270,13 +273,6 @@
            </property>
           </widget>
          </item>
-         <item row="4" column="0">
-          <widget class="QPushButton" name="btnFTPPublish">
-           <property name="text">
-            <string>Connexion FTP</string>
-           </property>
-          </widget>
-         </item>
          <item row="4" column="1">
           <widget class="QPushButton" name="btnPHP">
            <property name="text">
