ryxeo-webphotoalbum-git / original.cpp @ d044a969
Historique | Voir | Annoter | Télécharger (17,9 ko)
1 | b0972317 | Eric Seigne | /** Classe original: nom du projet prototype :)
|
---|---|---|---|
2 | ef177d24 | Eric Seigne | * @see https://redmine.ryxeo.com/projects/
|
3 | * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
|
||
4 | * @see The GNU Public License (GNU/GPL) v3
|
||
5 | *
|
||
6 | *
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or modify
|
||
9 | * it under the terms of the GNU General Public License as published by
|
||
10 | * the Free Software Foundation; either version 3 of the License, or
|
||
11 | * (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful, but
|
||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||
16 | * for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License along
|
||
19 | * with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
20 | */
|
||
21 | |||
22 | |||
23 | #include "original.h" |
||
24 | #include "ui_original.h" |
||
25 | |||
26 | 71c02254 | Eric Seigne | |
27 | //---------------------------------------------------------------------------
|
||
28 | QString formatSize(qint64 num) |
||
29 | { |
||
30 | QString total; |
||
31 | const qint64 kb = 1024; |
||
32 | const qint64 mb = 1024 * kb; |
||
33 | const qint64 gb = 1024 * mb; |
||
34 | const qint64 tb = 1024 * gb; |
||
35 | |||
36 | if (num >= tb) total = QString("%1TB").arg(QString::number(qreal(num) / tb, 'f', 2)); |
||
37 | else if(num >= gb) total = QString("%1GB").arg(QString::number(qreal(num) / gb, 'f', 2)); |
||
38 | else if(num >= mb) total = QString("%1MB").arg(QString::number(qreal(num) / mb, 'f', 1)); |
||
39 | else if(num >= kb) total = QString("%1KB").arg(QString::number(qreal(num) / kb,'f', 1)); |
||
40 | else total = QString("%1 bytes").arg(num); |
||
41 | |||
42 | return total;
|
||
43 | } |
||
44 | |||
45 | // =========================================================================================================================
|
||
46 | |||
47 | |||
48 | ef177d24 | Eric Seigne | original::original(QWidget *parent) : |
49 | QMainWindow(parent), |
||
50 | ui(new Ui::original)
|
||
51 | { |
||
52 | ui->setupUi(this);
|
||
53 | 92dc01fa | Eric Seigne | |
54 | a535756c | Eric Seigne | m_currentProjectPictureNumber = 0;
|
55 | |||
56 | db5783a6 | Eric Seigne | //Hop pour que le splitter soit a peu pres a la bonne taille dès le début
|
57 | QList<int> sizes;
|
||
58 | sizes.append(200);
|
||
59 | sizes.append(500);
|
||
60 | ui->splitter->setSizes(sizes); |
||
61 | |||
62 | d044a969 | Eric Seigne | m_baseDir = QDir(QDir::homePath() + "/RyXeo-Applications/WebPhotoAlbum");
|
63 | 61556262 | Eric Seigne | m_baseDir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
64 | d4b9f775 | Eric Seigne | QFileInfoList list = m_baseDir .entryInfoList(); |
65 | 92dc01fa | Eric Seigne | for(int i = 0; i < list.count(); i++) { |
66 | QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
|
||
67 | item->setText(0, list.at(i).fileName());
|
||
68 | item->setData(1,0,list.at(i).absoluteFilePath()); |
||
69 | } |
||
70 | d4a9c7c8 | Eric Seigne | |
71 | ui->dateEdit->setDate(QDate::currentDate()); |
||
72 | 293017f7 | Eric Seigne | m_tools = new tools(m_baseDir, this); |
73 | b489456c | Eric Seigne | |
74 | db5783a6 | Eric Seigne | //============== l'étiquette invitant a déposer des images
|
75 | m_labelDeposez = new QLabel(trUtf8("Glissez-déposez ici les photos que vous voulez ajouter à cet album ..."),ui->lwPictures); |
||
76 | m_labelDeposez->setStyleSheet("color: #aaa;\nfont-size: 24pt;\nfont-weight: bold;\n");
|
||
77 | m_labelDeposez->setScaledContents(true);
|
||
78 | m_labelDeposez->setWordWrap(true);
|
||
79 | m_labelDeposez->setAlignment(Qt::AlignCenter | Qt::AlignHCenter); |
||
80 | m_labelDeposez->hide(); |
||
81 | |||
82 | b489456c | Eric Seigne | //============== le menu contextuel du treewidget (gauche)
|
83 | m_menu = new QMenu(ui->treeWidget);
|
||
84 | QList<QAction*> actions; |
||
85 | |||
86 | QAction *a_nouveau = new QAction(QIcon(":/images/folder_add.png"),trUtf8("&Nouvel album"),m_menu); |
||
87 | a_nouveau->setIconVisibleInMenu(true);
|
||
88 | a_nouveau->connect(a_nouveau, SIGNAL(triggered()), this, SLOT(on_action_Nouvel_album_triggered()));
|
||
89 | |||
90 | QAction *a_renommer = new QAction(QIcon(":/images/folder_edit.png"),trUtf8("&Renommer..."),m_menu); |
||
91 | a_renommer->setIconVisibleInMenu(true);
|
||
92 | //a_renommer->connect(a_renommer, SIGNAL(triggered()), this, SLOT(on_action_Nouvel_album_triggered()));
|
||
93 | |||
94 | QAction *a_supprimer = new QAction(QIcon(":/images/folder_delete.png"),trUtf8("&Supprimer..."),m_menu); |
||
95 | a_supprimer->setIconVisibleInMenu(true);
|
||
96 | //a_supprimer->connect(a_supprimer, SIGNAL(triggered()), this, SLOT(on_action_Nouvel_album_triggered()));
|
||
97 | |||
98 | actions << a_nouveau << a_renommer << a_supprimer; |
||
99 | m_menu->addActions(actions); |
||
100 | d4b9f775 | Eric Seigne | |
101 | a535756c | Eric Seigne | //============== Accepte le drag & drop
|
102 | ui->lwPictures->setDragEnabled(true);
|
||
103 | ui->lwPictures->setDropIndicatorShown(true);
|
||
104 | ef177d24 | Eric Seigne | } |
105 | |||
106 | original::~original() |
||
107 | { |
||
108 | delete ui;
|
||
109 | } |
||
110 | |||
111 | 71c02254 | Eric Seigne | void original::on_action_Nouvel_album_triggered()
|
112 | { |
||
113 | a535756c | Eric Seigne | m_currentProjectPictureNumber = 0;
|
114 | 61556262 | Eric Seigne | bool ok;
|
115 | d4a9c7c8 | Eric Seigne | QString text = NewAlbumDialog::getValue(this);
|
116 | 61556262 | Eric Seigne | //Si ce nom n'existe pas déjà ...
|
117 | 71c02254 | Eric Seigne | QTreeWidgetItem *i = new QTreeWidgetItem(ui->treeWidget);
|
118 | 61556262 | Eric Seigne | i->setText(0, text);
|
119 | a535756c | Eric Seigne | m_currentProjectDir = m_baseDir.absolutePath() + "/" + text;
|
120 | 24cec736 | Eric Seigne | i->setData(1,0,m_currentProjectDir); |
121 | a535756c | Eric Seigne | |
122 | //Creation de la destination
|
||
123 | QDir rep; |
||
124 | rep.mkpath(m_currentProjectDir); |
||
125 | rep.mkpath(m_currentProjectDir + "/hq");
|
||
126 | rep.mkpath(m_currentProjectDir + "/lq");
|
||
127 | rep.mkpath(m_currentProjectDir + "/mq");
|
||
128 | rep.mkpath(m_currentProjectDir + "/thumbs");
|
||
129 | rep.mkpath(m_currentProjectDir + "/zip");
|
||
130 | rep.mkpath(m_currentProjectDir + "/comments");
|
||
131 | |||
132 | 71c02254 | Eric Seigne | } |
133 | |||
134 | 92dc01fa | Eric Seigne | void original::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column) |
135 | 71c02254 | Eric Seigne | { |
136 | db5783a6 | Eric Seigne | QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()+"/info.txt"); |
137 | qDebug() << "Lecture de " << fi.absoluteFilePath();
|
||
138 | |||
139 | //Remise a zero
|
||
140 | ui->leTitre->clear(); |
||
141 | ui->leAuthor->clear(); |
||
142 | ui->leDesc->clear(); |
||
143 | ui->dateEdit->clear(); |
||
144 | ui->leLogin->clear(); |
||
145 | ui->lePasswd->clear(); |
||
146 | |||
147 | if(fi.exists()) {
|
||
148 | QFile file(fi.absoluteFilePath()); |
||
149 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||
150 | return;
|
||
151 | |||
152 | /* Exemple de fichier
|
||
153 | name|Sortie Plongée SAGC. (Cala Montjoi, Spain) 28.05.2012
|
||
154 | author|Éric Seigne
|
||
155 | description|Sortie Plongée SAGC. (Cala Montjoi, Spain)
|
||
156 | date|28.05.2012
|
||
157 | restricted_user|sagc
|
||
158 | restricted_password|motdepasse
|
||
159 | */
|
||
160 | while (!file.atEnd()) {
|
||
161 | QByteArray line = file.readLine(); |
||
162 | QStringList tab = QString::fromUtf8(line.constData()).split('|');
|
||
163 | if(tab.at(0) == "name") |
||
164 | ui->leTitre->setText(tab.at(1));
|
||
165 | if(tab.at(0) == "author") |
||
166 | ui->leAuthor->setText(tab.at(1));
|
||
167 | if(tab.at(0) == "description") |
||
168 | ui->leDesc->setText(tab.at(1));
|
||
169 | d4a9c7c8 | Eric Seigne | if(tab.at(0) == "date") { |
170 | qDebug() << "**************** DATE : " << tab.at(1).trimmed(); |
||
171 | ui->dateEdit->setDate(QDate::fromString(tab.at(1).trimmed(),"dd.MM.yyyy")); |
||
172 | } |
||
173 | db5783a6 | Eric Seigne | if(tab.at(0) == "restricted_user") |
174 | ui->leLogin->setText(tab.at(1));
|
||
175 | if(tab.at(0) == "restricted_password") |
||
176 | ui->lePasswd->setText(tab.at(1));
|
||
177 | |||
178 | } |
||
179 | |||
180 | } |
||
181 | d4a9c7c8 | Eric Seigne | m_currentProjectPictureNumber++; |
182 | d8d0edae | Eric Seigne | refreshPictureList(); |
183 | db5783a6 | Eric Seigne | qDebug() << "On continue la numerotation a " << m_currentProjectPictureNumber;
|
184 | qDebug() << "Espace de stockage du projet " << m_currentProjectDir;
|
||
185 | 92dc01fa | Eric Seigne | } |
186 | |||
187 | void original::on_btnSave_clicked()
|
||
188 | 71c02254 | Eric Seigne | { |
189 | 8801fb5e | Eric Seigne | QByteArray data; |
190 | data.append(QString("name|%1\n").arg(ui->leTitre->text().trimmed()));
|
||
191 | data.append(QString("author|%1\n").arg(ui->leAuthor->text().trimmed()));
|
||
192 | data.append(QString("description|%1\n").arg(ui->leDesc->text().trimmed()));
|
||
193 | d4a9c7c8 | Eric Seigne | data.append(QString("date|%1\n").arg(ui->dateEdit->date().toString("dd.MM.yyyy"))); |
194 | 8801fb5e | Eric Seigne | if(ui->leLogin->text().trimmed() != "") { |
195 | data.append(QString("restricted_user|%1\n").arg(ui->leLogin->text().trimmed()));
|
||
196 | data.append(QString("restricted_password|%1\n").arg(ui->lePasswd->text().trimmed()));
|
||
197 | } |
||
198 | QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()+"/info.txt"); |
||
199 | qDebug() << "Ecriture de " << fi.absoluteFilePath();
|
||
200 | QFile file(fi.absoluteFilePath()); |
||
201 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||
202 | return;
|
||
203 | QTextStream out(&file); |
||
204 | out.setCodec("UTF-8");
|
||
205 | out << data; |
||
206 | file.close(); |
||
207 | 71c02254 | Eric Seigne | } |
208 | b489456c | Eric Seigne | |
209 | |||
210 | void original::on_treeWidget_customContextMenuRequested(const QPoint &pos) |
||
211 | { |
||
212 | m_menu->exec(ui->treeWidget->mapToGlobal(pos)); |
||
213 | } |
||
214 | d4b9f775 | Eric Seigne | |
215 | void original::dragEnterEvent(QDragEnterEvent *event)
|
||
216 | { |
||
217 | if (event->mimeData()->hasUrls())
|
||
218 | { |
||
219 | event->acceptProposedAction(); |
||
220 | } |
||
221 | else
|
||
222 | { |
||
223 | event->ignore(); |
||
224 | } |
||
225 | } |
||
226 | |||
227 | void original::dropEvent(QDropEvent *event)
|
||
228 | { |
||
229 | qDebug() << "Accepte le drop d'une image";
|
||
230 | |||
231 | if(event->mimeData()->hasUrls())
|
||
232 | { |
||
233 | for(int i = 0; i < event->mimeData()->urls().count(); i++) { |
||
234 | //recopier l'image dans le projet
|
||
235 | qDebug() << "Windows d&drop : " << event->mimeData()->urls().at(i).toString();
|
||
236 | a535756c | Eric Seigne | |
237 | d4b9f775 | Eric Seigne | //Attention sous windows le drag & drop est un file:/// sous linux file:// et osx ?
|
238 | #ifdef Q_OS_WIN32
|
||
239 | addPictureToProject(event->mimeData()->urls().at(i).toString().remove("file:///"));
|
||
240 | #endif
|
||
241 | #ifdef Q_OS_LINUX
|
||
242 | a535756c | Eric Seigne | addPictureToProject(event->mimeData()->urls().at(i).toString().remove("file://"));
|
243 | d4b9f775 | Eric Seigne | #endif
|
244 | qDebug() << "Accepte le drop d'une image";
|
||
245 | event->acceptProposedAction(); |
||
246 | } |
||
247 | } |
||
248 | } |
||
249 | a535756c | Eric Seigne | |
250 | void original::addPictureToProject(QString fic)
|
||
251 | { |
||
252 | ui->statusBar->clearMessage(); |
||
253 | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1").arg(fic),3000); |
||
254 | qApp->processEvents(); |
||
255 | |||
256 | d8d0edae | Eric Seigne | if(m_currentProjectPictureNumber == 0) |
257 | m_currentProjectPictureNumber = 1;
|
||
258 | |||
259 | a535756c | Eric Seigne | qDebug() << "Processing : " << fic;
|
260 | QPixmap pixmap(fic); |
||
261 | pixmap.save(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
||
262 | qDebug() << "Save to : " << QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber); |
||
263 | |||
264 | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq]").arg(fic),3000); |
||
265 | QPixmap pixmapThumbs(pixmap.scaled(QSize(120,120), Qt::KeepAspectRatio, Qt::SmoothTransformation)); |
||
266 | pixmapThumbs.save(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
||
267 | |||
268 | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq]").arg(fic),3000); |
||
269 | QPixmap pixmapMQ(pixmap.scaled(QSize(800,600), Qt::KeepAspectRatio, Qt::SmoothTransformation)); |
||
270 | pixmapMQ.save(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
||
271 | |||
272 | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq]").arg(fic),3000); |
||
273 | QPixmap pixmapLQ(pixmap.scaled(QSize(640,480), Qt::KeepAspectRatio, Qt::SmoothTransformation)); |
||
274 | pixmapLQ.save(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
||
275 | |||
276 | |||
277 | QFile file(QString("%1/comments/%2.txt").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber));
|
||
278 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||
279 | return;
|
||
280 | |||
281 | QTextStream out(&file); |
||
282 | out << "<span>Photo " + QString::number(m_currentProjectPictureNumber) + "</span>\n"; |
||
283 | file.close(); |
||
284 | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta]").arg(fic),3000); |
||
285 | |||
286 | //================== on copie les metadata
|
||
287 | d8d0edae | Eric Seigne | try {
|
288 | Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fic.toStdString()); |
||
289 | Exiv2::Image::AutoPtr imageLQ = Exiv2::ImageFactory::open(QString("%1/lq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
||
290 | Exiv2::Image::AutoPtr imageMQ = Exiv2::ImageFactory::open(QString("%1/mq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
||
291 | Exiv2::Image::AutoPtr imageHQ = Exiv2::ImageFactory::open(QString("%1/hq/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
||
292 | Exiv2::Image::AutoPtr imageThumb = Exiv2::ImageFactory::open(QString("%1/thumbs/img-%2.jpg").arg(m_currentProjectDir).arg(m_currentProjectPictureNumber).toStdString());
|
||
293 | if (image.get() != 0) |
||
294 | a535756c | Eric Seigne | { |
295 | d8d0edae | Eric Seigne | image->readMetadata(); |
296 | Exiv2::ExifData &exifData = image->exifData(); |
||
297 | if (!exifData.empty())
|
||
298 | a535756c | Eric Seigne | { |
299 | d8d0edae | Eric Seigne | bool setArtist = false; |
300 | bool setCopyright = false; |
||
301 | bool setSoftware = false; |
||
302 | Exiv2::ExifData::const_iterator end = exifData.end(); |
||
303 | d4a9c7c8 | Eric Seigne | // qDebug() << "============================ DEBUT ===============================";
|
304 | d8d0edae | Eric Seigne | for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
|
305 | { |
||
306 | d4a9c7c8 | Eric Seigne | // qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
|
307 | d8d0edae | Eric Seigne | if (i->key() == "Exif.Image.Artist") { |
308 | d044a969 | Eric Seigne | exifData["Exif.Image.Artist"] = ui->leAuthor->text().trimmed();
|
309 | d8d0edae | Eric Seigne | setArtist = true;
|
310 | } |
||
311 | if (i->key() == "Exif.Image.Copyright") { |
||
312 | d044a969 | Eric Seigne | exifData["Exif.Image.Copyright"] = ui->leAuthor->text().trimmed();
|
313 | d8d0edae | Eric Seigne | setCopyright = true;
|
314 | } |
||
315 | if (i->key() == "Exif.Image.Software") { |
||
316 | exifData["Exif.Image.Software"] = "RyXeo WebPhotoAlbum - http://www.ryxeo.com/"; |
||
317 | setSoftware = true;
|
||
318 | } |
||
319 | a535756c | Eric Seigne | } |
320 | d8d0edae | Eric Seigne | //Si on n'a pas les meta il faut les ajouter
|
321 | |||
322 | //Mise à jour de l'auteur
|
||
323 | if(!setArtist) {
|
||
324 | Exiv2::ExifKey k("Exif.Image.Artist");
|
||
325 | Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString); |
||
326 | d044a969 | Eric Seigne | v->read(ui->leAuthor->text().trimmed()); |
327 | d8d0edae | Eric Seigne | exifData.add(k,v.get()); |
328 | a535756c | Eric Seigne | } |
329 | |||
330 | d8d0edae | Eric Seigne | if(!setCopyright) {
|
331 | Exiv2::ExifKey k2("Exif.Image.Copyright");
|
||
332 | Exiv2::Value::AutoPtr v2 = Exiv2::Value::create(Exiv2::asciiString); |
||
333 | d044a969 | Eric Seigne | v2->read(ui->leAuthor->text().trimmed()); |
334 | d8d0edae | Eric Seigne | exifData.add(k2,v2.get()); |
335 | } |
||
336 | a535756c | Eric Seigne | |
337 | d8d0edae | Eric Seigne | if(!setSoftware) {
|
338 | Exiv2::ExifKey k3("Exif.Image.Software");
|
||
339 | Exiv2::Value::AutoPtr v3 = Exiv2::Value::create(Exiv2::asciiString); |
||
340 | v3->read("RyXéo WebPhotoAlbum - http://www.ryxeo.com/");
|
||
341 | exifData.add(k3,v3.get()); |
||
342 | } |
||
343 | a535756c | Eric Seigne | |
344 | d4a9c7c8 | Eric Seigne | // qDebug() << "============================ APRES ===============================";
|
345 | d8d0edae | Eric Seigne | Exiv2::ExifData::const_iterator end2 = exifData.end(); |
346 | d4a9c7c8 | Eric Seigne | // for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
|
347 | // {
|
||
348 | // qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
|
||
349 | // }
|
||
350 | // qDebug() << "============================ FIN ===============================";
|
||
351 | a535756c | Eric Seigne | |
352 | d8d0edae | Eric Seigne | imageLQ->setExifData(exifData); |
353 | imageLQ->writeMetadata(); |
||
354 | a535756c | Eric Seigne | |
355 | d8d0edae | Eric Seigne | imageMQ->setExifData(exifData); |
356 | imageMQ->writeMetadata(); |
||
357 | a535756c | Eric Seigne | |
358 | d8d0edae | Eric Seigne | imageHQ->setExifData(exifData); |
359 | imageHQ->writeMetadata(); |
||
360 | a535756c | Eric Seigne | |
361 | d8d0edae | Eric Seigne | imageThumb->setExifData(exifData); |
362 | imageThumb->writeMetadata(); |
||
363 | } |
||
364 | a535756c | Eric Seigne | } |
365 | } |
||
366 | d8d0edae | Eric Seigne | catch(...) {
|
367 | qDebug() << "Erreur EXIV2";
|
||
368 | } |
||
369 | a535756c | Eric Seigne | ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta] ... terminé").arg(fic),3000); |
370 | d4a9c7c8 | Eric Seigne | m_currentProjectPictureNumber++; |
371 | d8d0edae | Eric Seigne | refreshPictureList(); |
372 | a535756c | Eric Seigne | } |
373 | db5783a6 | Eric Seigne | |
374 | d8d0edae | Eric Seigne | void original::refreshPictureList()
|
375 | { |
||
376 | QTreeWidgetItem *item = ui->treeWidget->currentItem(); |
||
377 | ui->lwPictures->clear(); |
||
378 | m_currentProjectDir = item->data(1,0).toString(); |
||
379 | int currentProjectPictureNumber=0; |
||
380 | |||
381 | QDir dir(item->data(1,0).toString()+"/thumbs/"); |
||
382 | dir.setFilter(QDir::Files); |
||
383 | dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware); |
||
384 | QFileInfoList list = dir.entryInfoList(); |
||
385 | for(int i = 0; i < list.count(); i++) { |
||
386 | qDebug() << list.at(i).fileName(); |
||
387 | QListWidgetItem *newitem = new QListWidgetItem();
|
||
388 | QIcon icone(list.at(i).absoluteFilePath());//pour la mettre à coté de l'item
|
||
389 | newitem->setIcon(icone); // ajout de la petite icone sur l'item
|
||
390 | newitem->setText(list.at(i).fileName()); |
||
391 | ui->lwPictures->insertItem(i,newitem); |
||
392 | currentProjectPictureNumber = i+1;
|
||
393 | } |
||
394 | |||
395 | if(currentProjectPictureNumber == 0) { |
||
396 | qDebug() << "Pas d'image ... on affiche le message drag & drop";
|
||
397 | m_labelDeposez->resize(ui->lwPictures->size()); |
||
398 | m_labelDeposez->move(ui->lwPictures->pos()); |
||
399 | m_labelDeposez->show(); |
||
400 | qDebug() << m_labelDeposez->pos(); |
||
401 | qDebug() << m_labelDeposez->size(); |
||
402 | } |
||
403 | else {
|
||
404 | m_labelDeposez->hide(); |
||
405 | } |
||
406 | d4a9c7c8 | Eric Seigne | m_currentProjectPictureNumber = currentProjectPictureNumber+1;
|
407 | d8d0edae | Eric Seigne | } |
408 | |||
409 | bbebc37b | Eric Seigne | void original::on_btnUpload_clicked()
|
410 | { |
||
411 | 5ea3da39 | Eric Seigne | qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString(); |
412 | 293017f7 | Eric Seigne | m_tools->clear(); |
413 | 5ea3da39 | Eric Seigne | |
414 | d4a9c7c8 | Eric Seigne | m_tools->ftpConnect(ui->leFTPServeur->text(), |
415 | ui->leFTPLogin->text(), |
||
416 | ui->leFTPPass->text()); |
||
417 | |||
418 | m_tools->ftpMkdir(ui->leFTPDirectory->text()); |
||
419 | m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries");
|
||
420 | m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0)); |
||
421 | |||
422 | //On uploade la gallerie
|
||
423 | //m_ftp->cd(ui->leFTPDirectory->text());
|
||
424 | |||
425 | QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()); |
||
426 | QDir dir(fi.absoluteFilePath()); |
||
427 | 04d4d726 | Eric Seigne | m_tools->parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0));
|
428 | d4a9c7c8 | Eric Seigne | //qDebug() << m_fileListToUpload;
|
429 | m_tools->uploadRecursifGallery(ui->leFTPDirectory->text()); |
||
430 | connect(m_tools, SIGNAL(signalUpload(int,int)), this, SLOT(updateProgressFichier(int,int))); |
||
431 | connect(m_tools, SIGNAL(signalUploadData(int,int)), this, SLOT(updateProgressData(int,int))); |
||
432 | f68f673d | Eric Seigne | } |
433 | 293017f7 | Eric Seigne | |
434 | void original::on_action_Assistant_d_installation_triggered()
|
||
435 | { |
||
436 | Assistant *a = new Assistant(this); |
||
437 | a->show(); |
||
438 | } |
||
439 | d4a9c7c8 | Eric Seigne | |
440 | void original::updateProgressFichier(int total, int current) |
||
441 | { |
||
442 | ui->pbFTPFichier->setMaximum(total); |
||
443 | ui->pbFTPFichier->setValue(current); |
||
444 | } |
||
445 | |||
446 | void original::updateProgressData(int total, int current) |
||
447 | { |
||
448 | ui->pbFTPProgress->setMaximum(total); |
||
449 | ui->pbFTPProgress->setValue(current); |
||
450 | } |