|
10 | 10 |
|
11 | 11 | import exifread |
12 | 12 | import imagesize |
13 | | -from PySide6.QtCore import (QAbstractListModel, QModelIndex, QPoint, QRect, |
14 | | - QSize, Qt, Signal, Slot) |
| 13 | +from PySide6.QtCore import (QAbstractListModel, QModelIndex, QMimeData, QPoint, |
| 14 | + QRect, QSize, Qt, QUrl, Signal, Slot) |
15 | 15 | from PySide6.QtGui import QIcon, QImageReader, QPixmap |
16 | 16 | from PySide6.QtWidgets import QMessageBox |
17 | 17 |
|
@@ -63,6 +63,25 @@ def __init__(self, image_list_image_width: int, tag_separator: str): |
63 | 63 | self.proxy_image_list_model = None |
64 | 64 | self.image_list_selection_model = None |
65 | 65 |
|
| 66 | + def flags(self, index): |
| 67 | + default_flags = super().flags(index) |
| 68 | + if index.isValid(): |
| 69 | + return Qt.ItemFlags.ItemIsDragEnabled | default_flags |
| 70 | + return default_flags |
| 71 | + |
| 72 | + def mimeTypes(self): |
| 73 | + return ('text/uri-list', 'text/plain') |
| 74 | + |
| 75 | + def mimeData(self, indexes): |
| 76 | + mimeData = QMimeData() |
| 77 | + mimeData.setUrls([QUrl('file://' + str(self.data( |
| 78 | + image_index, Qt.ItemDataRole.UserRole |
| 79 | + ).path)) for image_index in indexes]) |
| 80 | + mimeData.setText('\r\n'.join(['file://' + str(self.data( |
| 81 | + image_index, Qt.ItemDataRole.UserRole |
| 82 | + ).path) for image_index in indexes])) |
| 83 | + return mimeData |
| 84 | + |
66 | 85 | def rowCount(self, parent=None) -> int: |
67 | 86 | return len(self.images) |
68 | 87 |
|
|
0 commit comments