5 |
5 |
6 """ |
6 """ |
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 PyQt4.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent |
10 from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint, QEvent |
11 from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, QToolButton |
11 from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, QToolButton |
12 |
12 |
13 from .E5ModelMenu import E5ModelMenu |
13 from .E5ModelMenu import E5ModelMenu |
14 |
14 |
15 |
15 |
240 assert idx.isValid() |
240 assert idx.isValid() |
241 |
241 |
242 drag = QDrag(self) |
242 drag = QDrag(self) |
243 drag.setMimeData(self.__model.mimeData([idx])) |
243 drag.setMimeData(self.__model.mimeData([idx])) |
244 actionRect = self.actionGeometry(act) |
244 actionRect = self.actionGeometry(act) |
245 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
245 if qVersion() >= "5.0.0": |
|
246 drag.setPixmap(self.grab(actionRect)) |
|
247 else: |
|
248 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
246 |
249 |
247 if drag.exec_() == Qt.MoveAction: |
250 if drag.exec_() == Qt.MoveAction: |
248 row = idx.row() |
251 row = idx.row() |
249 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
252 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
250 row += 1 |
253 row += 1 |