7 Module implementing a menu populated from a QAbstractItemModel. |
7 Module implementing a menu populated from a QAbstractItemModel. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSignal, qVersion, 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, QPixmap |
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 |
17 |
18 |
18 |
19 |
19 class E5ModelMenu(QMenu): |
20 class E5ModelMenu(QMenu): |
20 """ |
21 """ |
21 Class implementing a menu populated from a QAbstractItemModel. |
22 Class implementing a menu populated from a QAbstractItemModel. |
386 return |
387 return |
387 |
388 |
388 drag = QDrag(self) |
389 drag = QDrag(self) |
389 drag.setMimeData(self.__model.mimeData([idx])) |
390 drag.setMimeData(self.__model.mimeData([idx])) |
390 actionRect = self.actionGeometry(act) |
391 actionRect = self.actionGeometry(act) |
391 if qVersion() >= "5.0.0": |
392 if qVersionTuple() >= (5, 0, 0): |
392 drag.setPixmap(self.grab(actionRect)) |
393 drag.setPixmap(self.grab(actionRect)) |
393 else: |
394 else: |
394 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
395 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
395 |
396 |
396 if drag.exec_() == Qt.MoveAction: |
397 if drag.exec_() == Qt.MoveAction: |