Révision d4b9f775
original.cpp | ||
---|---|---|
56 | 56 |
|
57 | 57 |
m_baseDir = QDir(QDir::homePath() + "/RyXeo-WebPhotoAlbum"); |
58 | 58 |
m_baseDir.setFilter(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
59 |
QFileInfoList list = m_baseDir.entryInfoList(); |
|
59 |
QFileInfoList list = m_baseDir .entryInfoList();
|
|
60 | 60 |
for(int i = 0; i < list.count(); i++) { |
61 | 61 |
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget); |
62 | 62 |
item->setText(0, list.at(i).fileName()); |
... | ... | |
81 | 81 |
|
82 | 82 |
actions << a_nouveau << a_renommer << a_supprimer; |
83 | 83 |
m_menu->addActions(actions); |
84 |
|
|
85 |
//============== le menu contextuel du treewidget (gauche) |
|
86 |
ui->lwPictures->setDragEnabled(true); |
|
87 |
ui->lwPictures->setDropIndicatorShown(true); |
|
84 | 88 |
} |
85 | 89 |
|
86 | 90 |
original::~original() |
... | ... | |
318 | 322 |
{ |
319 | 323 |
m_menu->exec(ui->treeWidget->mapToGlobal(pos)); |
320 | 324 |
} |
325 |
|
|
326 |
void original::dragEnterEvent(QDragEnterEvent *event) |
|
327 |
{ |
|
328 |
if (event->mimeData()->hasUrls()) |
|
329 |
{ |
|
330 |
event->acceptProposedAction(); |
|
331 |
} |
|
332 |
else |
|
333 |
{ |
|
334 |
event->ignore(); |
|
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
void original::dropEvent(QDropEvent *event) |
|
339 |
{ |
|
340 |
qDebug() << "Accepte le drop d'une image"; |
|
341 |
|
|
342 |
if(event->mimeData()->hasUrls()) |
|
343 |
{ |
|
344 |
for(int i = 0; i < event->mimeData()->urls().count(); i++) { |
|
345 |
//recopier l'image dans le projet |
|
346 |
qDebug() << "Windows d&drop : " << event->mimeData()->urls().at(i).toString(); |
|
347 |
/* |
|
348 |
//Attention sous windows le drag & drop est un file:/// sous linux file:// et osx ? |
|
349 |
#ifdef Q_OS_WIN32 |
|
350 |
addPictureToProject(event->mimeData()->urls().at(i).toString().remove("file:///")); |
|
351 |
#endif |
|
352 |
#ifdef Q_OS_LINUX |
|
353 |
QString f(event->mimeData()->urls().at(i).toString().remove("file://")); |
|
354 |
qDebug() << "On importe par d&d le fichier " << f; |
|
355 |
addPictureToProject(f); |
|
356 |
#endif |
|
357 |
*/ |
|
358 |
qDebug() << "Accepte le drop d'une image"; |
|
359 |
event->acceptProposedAction(); |
|
360 |
} |
|
361 |
} |
|
362 |
} |
original.h | ||
---|---|---|
33 | 33 |
#include <QListWidgetItem> |
34 | 34 |
#include <QMenu> |
35 | 35 |
#include <QInputDialog> |
36 |
#include <QDragEnterEvent> |
|
37 |
#include <QUrl> |
|
36 | 38 |
|
37 | 39 |
|
38 | 40 |
namespace Ui { |
... | ... | |
53 | 55 |
void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); |
54 | 56 |
void on_commandLinkButton_clicked(); |
55 | 57 |
void on_btnSave_clicked(); |
56 |
|
|
57 | 58 |
void on_treeWidget_customContextMenuRequested(const QPoint &pos); |
59 |
//Gestion du drop d'image venant de l'extérieur |
|
60 |
void dragEnterEvent(QDragEnterEvent *event); |
|
61 |
void dropEvent(QDropEvent *event); |
|
58 | 62 |
|
59 | 63 |
private: |
60 | 64 |
Ui::original *ui; |
original.ui | ||
---|---|---|
10 | 10 |
<height>457</height> |
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 |
<property name="acceptDrops"> |
|
14 |
<bool>true</bool> |
|
15 |
</property> |
|
13 | 16 |
<property name="windowTitle"> |
14 | 17 |
<string>original</string> |
15 | 18 |
</property> |
16 | 19 |
<widget class="QWidget" name="centralWidget"> |
20 |
<property name="acceptDrops"> |
|
21 |
<bool>true</bool> |
|
22 |
</property> |
|
17 | 23 |
<layout class="QGridLayout" name="gridLayout"> |
18 | 24 |
<item row="0" column="1"> |
19 | 25 |
<widget class="QFrame" name="frmPrincipale"> |
... | ... | |
61 | 67 |
<item row="1" column="0" colspan="4"> |
62 | 68 |
<widget class="QStackedWidget" name="stackedWidget"> |
63 | 69 |
<property name="currentIndex"> |
64 |
<number>1</number>
|
|
70 |
<number>0</number>
|
|
65 | 71 |
</property> |
66 | 72 |
<widget class="QWidget" name="page"> |
67 | 73 |
<layout class="QGridLayout" name="gridLayout_4"> |
68 | 74 |
<item row="0" column="0"> |
69 | 75 |
<widget class="QListWidget" name="lwPictures"> |
76 |
<property name="acceptDrops"> |
|
77 |
<bool>true</bool> |
|
78 |
</property> |
|
70 | 79 |
<property name="iconSize"> |
71 | 80 |
<size> |
72 | 81 |
<width>120</width> |
Formats disponibles : Unified diff