7 Module implementing a tool bar populated from a QAbstractItemModel. |
7 Module implementing a tool bar 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, QEvent |
12 from PyQt5.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent |
13 from PyQt5.QtGui import QDrag, QPixmap, QIcon |
13 from PyQt5.QtGui import QDrag, QPixmap, QIcon |
14 from PyQt5.QtWidgets import QApplication, QToolBar, QToolButton |
14 from PyQt5.QtWidgets import QApplication, QToolBar, QToolButton |
|
15 |
|
16 from Globals import qVersionTuple |
15 |
17 |
16 |
18 |
17 class E5ModelToolBar(QToolBar): |
19 class E5ModelToolBar(QToolBar): |
18 """ |
20 """ |
19 Class implementing a tool bar populated from a QAbstractItemModel. |
21 Class implementing a tool bar populated from a QAbstractItemModel. |
249 assert idx.isValid() |
251 assert idx.isValid() |
250 |
252 |
251 drag = QDrag(self) |
253 drag = QDrag(self) |
252 drag.setMimeData(self.__model.mimeData([idx])) |
254 drag.setMimeData(self.__model.mimeData([idx])) |
253 actionRect = self.actionGeometry(act) |
255 actionRect = self.actionGeometry(act) |
254 if qVersion() >= "5.0.0": |
256 if qVersionTuple() >= (5, 0, 0): |
255 drag.setPixmap(self.grab(actionRect)) |
257 drag.setPixmap(self.grab(actionRect)) |
256 else: |
258 else: |
257 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
259 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
258 |
260 |
259 if drag.exec_() == Qt.MoveAction: |
261 if drag.exec_() == Qt.MoveAction: |