Projet

Général

Profil

Révision 92dc01fa original.cpp

Voir les différences:

original.cpp
25 25
#include "ui_original.h"
26 26

  
27 27

  
28
//---------------------------------------------------------------------------------
29
bool viewsSortProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
30
{
31
    if(this->filterRegExp().isEmpty()) return true;
32

  
33
    QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
34
    myModel* fileModel = qobject_cast<myModel*>(sourceModel());
35

  
36
    if(fileModel->fileInfo(index0).isHidden()) return false;
37
    else return true;
38
}
39

  
40

  
41
//---------------------------------------------------------------------------------
42
bool viewsSortProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
43
{
44
    myModel* fsModel = dynamic_cast<myModel*>(sourceModel());
45

  
46
    if(left.column() == 1)          //size
47
    {
48
        if(fsModel->size(left) > fsModel->size(right)) return true;
49
        else return false;
50
    }
51
    else
52
    if(left.column() == 3)          //date
53
    {
54
        if(fsModel->fileInfo(left).lastModified() > fsModel->fileInfo(right).lastModified()) return true;
55
        else return false;
56
    }
57

  
58
    return QSortFilterProxyModel::lessThan(left,right);
59
}
60

  
61
//---------------------------------------------------------------------------------
62
QStringList myCompleter::splitPath(const QString& path) const
63
{
64
    QStringList parts = path.split("/");
65
    parts[0] = "/";
66

  
67
    return parts;
68
}
69

  
70
//---------------------------------------------------------------------------------
71
QString myCompleter::pathFromIndex(const QModelIndex& index) const
72
{
73
    if(!index.isValid()) return "";
74

  
75
    QModelIndex idx = index;
76
    QStringList list;
77
    do
78
    {
79
        QString t = model()->data(idx, Qt::EditRole).toString();
80
        list.prepend(t);
81
        QModelIndex parent = idx.parent();
82
        idx = parent.sibling(parent.row(), index.column());
83
    }
84
    while (idx.isValid());
85

  
86
    list[0].clear() ; // the join below will provide the separator
87

  
88
    return list.join("/");
89
}
90

  
91 28
//---------------------------------------------------------------------------
92 29
QString formatSize(qint64 num)
93 30
{
......
114 51
    ui(new Ui::original)
115 52
{
116 53
    ui->setupUi(this);
54

  
55
    ui->stackedWidget->setCurrentWidget(ui->page);
56

  
57
    QDir dir(QDir::homePath() + "/RyXeo-WebPhotoAlbum");
58
    dir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
59
    QFileInfoList list = dir.entryInfoList();
60
    for(int i = 0; i < list.count(); i++) {
61
        QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
62
        item->setText(0, list.at(i).fileName());
63
        item->setData(1,0,list.at(i).absoluteFilePath());
64
    }
117 65
}
118 66

  
119 67
original::~original()
......
190 138
                {
191 139
                    qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
192 140
                    if (i->key() == "Exif.Image.Artist") {
193
                        exifData["Exif.Image.Artist"]    = "Toto le hero";
141
                        exifData["Exif.Image.Artist"]    = "Eric S.";
194 142
                        setArtist = true;
195 143
                    }
196 144
                    if (i->key() == "Exif.Image.Copyright") {
197
                        exifData["Exif.Image.Copyright"]    = "Toto le hero";
145
                        exifData["Exif.Image.Copyright"]    = "Eric S.";
198 146
                        setCopyright = true;
199 147
                    }
200 148
                    if (i->key() == "Exif.Image.Software") {
......
208 156
                if(!setArtist) {
209 157
                    Exiv2::ExifKey k("Exif.Image.Artist");
210 158
                    Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
211
                    v->read("Toto le hero");
159
                    v->read("Eric S.");
212 160
                    exifData.add(k,v.get());
213 161
                }
214 162

  
215 163
                if(!setCopyright) {
216 164
                    Exiv2::ExifKey k2("Exif.Image.Copyright");
217 165
                    Exiv2::Value::AutoPtr v2 = Exiv2::Value::create(Exiv2::asciiString);
218
                    v2->read("Toto le hero");
166
                    v2->read("Eric S.");
219 167
                    exifData.add(k2,v2.get());
220 168
                }
221 169

  
......
257 205
    i->setText(0, trUtf8("Nouvel album"));
258 206
}
259 207

  
260
//---------------------------------------------------------------------------
261
void original::thumbUpdate(QModelIndex index)
208
void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
262 209
{
263
    qDebug() << "original::thumbUpdate";
264
    ui->lvResult->update(m_modelView->mapFromSource(index));
210
    ui->lwPictures->clear();
211
    QDir dir(item->data(1,0).toString()+"/thumbs/");
212
    dir.setFilter(QDir::Files);
213
    dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
214
    QFileInfoList list = dir.entryInfoList();
215
    for(int i = 0; i < list.count(); i++) {
216
        qDebug() << list.at(i).fileName();
217
        QListWidgetItem *newitem = new QListWidgetItem();
218
        QIcon icone(list.at(i).absoluteFilePath());//pour la mettre  à coté de l'item
219
        newitem->setIcon(icone); // ajout de la petite icone sur l'item
220
        newitem->setText(list.at(i).fileName());
221
        ui->lwPictures->insertItem(i,newitem);
222
    }
265 223
}
266 224

  
267
void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
225
void original::on_commandLinkButton_clicked()
226
{
227
    if(ui->stackedWidget->currentWidget() == ui->page_2)
228
        ui->stackedWidget->setCurrentWidget(ui->page);
229
    else {
230
        QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()+"/info.txt");
231
        qDebug() << "Lecture de " << fi.absoluteFilePath();
232
        if(fi.exists()) {
233
            QFile file(fi.absoluteFilePath());
234
            if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
235
                return;
236

  
237
            /* Exemple de fichier
238
            name|Sortie Plongée SAGC. (Cala Montjoi, Spain) 28.05.2012
239
            author|Éric Seigne
240
            description|Sortie Plongée SAGC. (Cala Montjoi, Spain)
241
            date|28.05.2012
242
            restricted_user|sagc
243
            restricted_password|motdepasse
244
              */
245
            while (!file.atEnd()) {
246
                QByteArray line = file.readLine();
247
                QStringList tab = QString::fromUtf8(line.constData()).split('|');
248
                if(tab.at(0) == "name")
249
                    ui->leTitre->setText(tab.at(1));
250
                if(tab.at(0) == "author")
251
                    ui->leAuthor->setText(tab.at(1));
252
                if(tab.at(0) == "description")
253
                    ui->leDesc->setText(tab.at(1));
254
                if(tab.at(0) == "date")
255
                    ui->dateEdit->setDate(QDate::fromString(tab.at(1)));
256
                if(tab.at(0) == "restricted_user")
257
                    ui->leLogin->setText(tab.at(1));
258
                if(tab.at(0) == "restricted_password")
259
                    ui->lePasswd->setText(tab.at(1));
260

  
261
            }
262

  
263
        }
264
        ui->stackedWidget->setCurrentWidget(ui->page_2);
265
    }
266
}
267

  
268
void original::on_btnSave_clicked()
268 269
{
269
    QStringList items;
270
    m_modelList = new myModel();
271
    m_modelList->setRootPath("/tmp/");
272

  
273
    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-000.jpg");
274
    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-001.jpg");
275
    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-002.jpg");
276
    m_modelList->populateItem("/tmp/t/20120529-lea_plongee_cala_montjoi-003.jpg");
277
    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-000.jpg");
278
    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-001.jpg");
279
    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-002.jpg");
280
    items.append("/tmp/t/20120529-lea_plongee_cala_montjoi-003.jpg");
281
    QtConcurrent::run(m_modelList,&myModel::loadThumbsQSL,items);
282

  
283
    m_modelView = new viewsSortProxyModel();
284
    m_modelView->setSourceModel(m_modelList);
285
    m_modelView->setSortCaseSensitivity(Qt::CaseInsensitive);
286
    ui->lvResult->setModel(m_modelView);
287

  
288
    connect(m_modelList,SIGNAL(thumbUpdate(QModelIndex)),this,SLOT(thumbUpdate(QModelIndex)));
289 270

  
290 271
}

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux