8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSignal, Qt, QModelIndex, QPoint |
12 from PyQt5.QtCore import pyqtSignal, Qt, QModelIndex, QPoint |
13 from PyQt5.QtGui import QFontMetrics, QDrag, QPixmap |
13 from PyQt5.QtGui import QFontMetrics, QDrag |
14 from PyQt5.QtWidgets import QMenu, QAction, QApplication |
14 from PyQt5.QtWidgets import QMenu, QAction, QApplication |
15 |
15 |
16 import UI.PixmapCache |
16 import UI.PixmapCache |
17 from Globals import qVersionTuple |
|
18 |
17 |
19 |
18 |
20 class E5ModelMenu(QMenu): |
19 class E5ModelMenu(QMenu): |
21 """ |
20 """ |
22 Class implementing a menu populated from a QAbstractItemModel. |
21 Class implementing a menu populated from a QAbstractItemModel. |
391 return |
390 return |
392 |
391 |
393 drag = QDrag(self) |
392 drag = QDrag(self) |
394 drag.setMimeData(self.__model.mimeData([idx])) |
393 drag.setMimeData(self.__model.mimeData([idx])) |
395 actionRect = self.actionGeometry(act) |
394 actionRect = self.actionGeometry(act) |
396 if qVersionTuple() >= (5, 0, 0): |
395 drag.setPixmap(self.grab(actionRect)) |
397 drag.setPixmap(self.grab(actionRect)) |
|
398 else: |
|
399 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
|
400 |
396 |
401 if drag.exec_() == Qt.MoveAction: |
397 if drag.exec_() == Qt.MoveAction: |
402 row = idx.row() |
398 row = idx.row() |
403 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
399 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
404 row += 1 |
400 row += 1 |