commit 92dc01fa2267296f3d1fb9771c8253a573803ee1
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Mon Jun 4 00:06:08 2012 +0200

    lecture du fichier info.txt ok

diff --git a/original.cpp b/original.cpp
index 80be230..d5196a8 100644
--- a/original.cpp
+++ b/original.cpp
@@ -25,69 +25,6 @@
 #include "ui_original.h"
 
 
-//---------------------------------------------------------------------------------
-bool viewsSortProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
-{
-    if(this->filterRegExp().isEmpty()) return true;
-
-    QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
-    myModel* fileModel = qobject_cast<myModel*>(sourceModel());
-
-    if(fileModel->fileInfo(index0).isHidden()) return false;
-    else return true;
-}
-
-
-//---------------------------------------------------------------------------------
-bool viewsSortProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
-{
-    myModel* fsModel = dynamic_cast<myModel*>(sourceModel());
-
-    if(left.column() == 1)          //size
-    {
-        if(fsModel->size(left) > fsModel->size(right)) return true;
-        else return false;
-    }
-    else
-    if(left.column() == 3)          //date
-    {
-        if(fsModel->fileInfo(left).lastModified() > fsModel->fileInfo(right).lastModified()) return true;
-        else return false;
-    }
-
-    return QSortFilterProxyModel::lessThan(left,right);
-}
-
-//---------------------------------------------------------------------------------
-QStringList myCompleter::splitPath(const QString& path) const
-{
-    QStringList parts = path.split("/");
-    parts[0] = "/";
-
-    return parts;
-}
-
-//---------------------------------------------------------------------------------
-QString myCompleter::pathFromIndex(const QModelIndex& index) const
-{
-    if(!index.isValid()) return "";
-
-    QModelIndex idx = index;
-    QStringList list;
-    do
-    {
-        QString t = model()->data(idx, Qt::EditRole).toString();
-        list.prepend(t);
-        QModelIndex parent = idx.parent();
-        idx = parent.sibling(parent.row(), index.column());
-    }
-    while (idx.isValid());
-
-    list[0].clear() ; // the join below will provide the separator
-
-    return list.join("/");
-}
-
 //---------------------------------------------------------------------------
 QString formatSize(qint64 num)
 {
@@ -114,6 +51,17 @@ original::original(QWidget *parent) :
     ui(new Ui::original)
 {
     ui->setupUi(this);
+
+    ui->stackedWidget->setCurrentWidget(ui->page);
+
+    QDir dir(QDir::homePath() + "/RyXeo-WebPhotoAlbum");
+    dir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+    QFileInfoList list = dir.entryInfoList();
+    for(int i = 0; i < list.count(); i++) {
+        QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
+        item->setText(0, list.at(i).fileName());
+        item->setData(1,0,list.at(i).absoluteFilePath());
+    }
 }
 
 original::~original()
@@ -190,11 +138,11 @@ void original::on_btnExport_clicked()
                 {
                     qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
                     if (i->key() == "Exif.Image.Artist") {
-                        exifData["Exif.Image.Artist"]    = "Toto le hero";
+                        exifData["Exif.Image.Artist"]    = "Eric S.";
                         setArtist = true;
                     }
                     if (i->key() == "Exif.Image.Copyright") {
-                        exifData["Exif.Image.Copyright"]    = "Toto le hero";
+                        exifData["Exif.Image.Copyright"]    = "Eric S.";
                         setCopyright = true;
                     }
                     if (i->key() == "Exif.Image.Software") {
@@ -208,14 +156,14 @@ void original::on_btnExport_clicked()
                 if(!setArtist) {
                     Exiv2::ExifKey k("Exif.Image.Artist");
                     Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
-                    v->read("Toto le hero");
+                    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("Toto le hero");
+                    v2->read("Eric S.");
                     exifData.add(k2,v2.get());
                 }
 
@@ -257,34 +205,67 @@ void original::on_action_Nouvel_album_triggered()
     i->setText(0, trUtf8("Nouvel album"));
 }
 
-//---------------------------------------------------------------------------
-void original::thumbUpdate(QModelIndex index)
+void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
 {
-    qDebug() << "original::thumbUpdate";
-    ui->lvResult->update(m_modelView->mapFromSource(index));
+    ui->lwPictures->clear();
+    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);
+    }
 }
 
-void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
+void original::on_commandLinkButton_clicked()
+{
+    if(ui->stackedWidget->currentWidget() == ui->page_2)
+        ui->stackedWidget->setCurrentWidget(ui->page);
+    else {
+        QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()+"/info.txt");
+        qDebug() << "Lecture de " << fi.absoluteFilePath();
+        if(fi.exists()) {
+            QFile file(fi.absoluteFilePath());
+            if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+                return;
+
+            /* Exemple de fichier
+            name|Sortie Plongée SAGC. (Cala Montjoi, Spain) 28.05.2012
+            author|Éric Seigne
+            description|Sortie Plongée SAGC. (Cala Montjoi, Spain)
+            date|28.05.2012
+            restricted_user|sagc
+            restricted_password|motdepasse
+              */
+            while (!file.atEnd()) {
+                QByteArray line = file.readLine();
+                QStringList tab = QString::fromUtf8(line.constData()).split('|');
+                if(tab.at(0) == "name")
+                    ui->leTitre->setText(tab.at(1));
+                if(tab.at(0) == "author")
+                    ui->leAuthor->setText(tab.at(1));
+                if(tab.at(0) == "description")
+                    ui->leDesc->setText(tab.at(1));
+                if(tab.at(0) == "date")
+                    ui->dateEdit->setDate(QDate::fromString(tab.at(1)));
+                if(tab.at(0) == "restricted_user")
+                    ui->leLogin->setText(tab.at(1));
+                if(tab.at(0) == "restricted_password")
+                    ui->lePasswd->setText(tab.at(1));
+
+            }
+
+        }
+        ui->stackedWidget->setCurrentWidget(ui->page_2);
+    }
+}
+
+void original::on_btnSave_clicked()
 {
-    QStringList items;
-    m_modelList = new myModel();
-    m_modelList->setRootPath("/tmp/");
-
-    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-000.jpg");
-    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-001.jpg");
-    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-002.jpg");
-    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-003.jpg");
-    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-000.jpg");
-    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-001.jpg");
-    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-002.jpg");
-    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-003.jpg");
-    QtConcurrent::run(m_modelList,&myModel::loadThumbsQSL,items);
-
-    m_modelView = new viewsSortProxyModel();
-    m_modelView->setSourceModel(m_modelList);
-    m_modelView->setSortCaseSensitivity(Qt::CaseInsensitive);
-    ui->lvResult->setModel(m_modelView);
-
-    connect(m_modelList,SIGNAL(thumbUpdate(QModelIndex)),this,SLOT(thumbUpdate(QModelIndex)));
 
 }
