Mercurial > minori
comparison src/gui/widgets/drop_list_widget.cc @ 370:ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:22:04 -0400 |
parents | b1f4d1867ab1 |
children |
comparison
equal
deleted
inserted
replaced
369:47c9f8502269 | 370:ea3a74ed2ef9 |
---|---|
1 #include "gui/widgets/drop_list_widget.h" | 1 #include "gui/widgets/drop_list_widget.h" |
2 | 2 |
3 #include <QDragMoveEvent> | 3 #include <QDragMoveEvent> |
4 #include <QDropEvent> | 4 #include <QDropEvent> |
5 #include <QFileInfo> | |
5 #include <QMimeData> | 6 #include <QMimeData> |
6 #include <QFileInfo> | |
7 | 7 |
8 /* currently this only sends local paths that are folders */ | 8 /* currently this only sends local paths that are folders */ |
9 | 9 |
10 DroppableListWidget::DroppableListWidget(QWidget* parent) : QListWidget(parent) { | 10 DroppableListWidget::DroppableListWidget(QWidget *parent) : QListWidget(parent) |
11 { | |
11 setAcceptDrops(true); | 12 setAcceptDrops(true); |
12 } | 13 } |
13 | 14 |
14 void DroppableListWidget::dragMoveEvent(QDragMoveEvent* event) { | 15 void DroppableListWidget::dragMoveEvent(QDragMoveEvent *event) |
16 { | |
15 if (event->mimeData()->hasUrls()) | 17 if (event->mimeData()->hasUrls()) |
16 event->acceptProposedAction(); | 18 event->acceptProposedAction(); |
17 } | 19 } |
18 | 20 |
19 void DroppableListWidget::dragEnterEvent(QDragEnterEvent* event) { | 21 void DroppableListWidget::dragEnterEvent(QDragEnterEvent *event) |
22 { | |
20 if (event->mimeData()->hasUrls()) | 23 if (event->mimeData()->hasUrls()) |
21 event->acceptProposedAction(); | 24 event->acceptProposedAction(); |
22 } | 25 } |
23 | 26 |
24 void DroppableListWidget::dropEvent(QDropEvent* event) { | 27 void DroppableListWidget::dropEvent(QDropEvent *event) |
25 const QMimeData* mime_data = event->mimeData(); | 28 { |
29 const QMimeData *mime_data = event->mimeData(); | |
26 | 30 |
27 if (!mime_data->hasUrls()) | 31 if (!mime_data->hasUrls()) |
28 return; | 32 return; |
29 | 33 |
30 QStringList path_list; | 34 QStringList path_list; |
31 QList<QUrl> url_list = mime_data->urls(); | 35 QList<QUrl> url_list = mime_data->urls(); |
32 | 36 |
33 for (const auto& url : url_list) { | 37 for (const auto &url : url_list) { |
34 if (!url.isLocalFile()) | 38 if (!url.isLocalFile()) |
35 continue; | 39 continue; |
36 | 40 |
37 const QString file = url.toLocalFile(); | 41 const QString file = url.toLocalFile(); |
38 const QFileInfo fileinfo(file); | 42 const QFileInfo fileinfo(file); |