5 |
5 |
6 """ |
6 """ |
7 Module implementing a menu populated from a QAbstractItemModel. |
7 Module implementing a menu populated from a QAbstractItemModel. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtCore import pyqtSignal, Qt, QModelIndex, QPoint |
10 from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint |
11 from PyQt4.QtGui import QMenu, QFontMetrics, QAction, QApplication, QDrag, QPixmap |
11 from PyQt4.QtGui import QMenu, QFontMetrics, QAction, QApplication, QDrag, QPixmap |
12 |
12 |
13 import UI.PixmapCache |
13 import UI.PixmapCache |
14 |
14 |
15 |
15 |
376 return |
376 return |
377 |
377 |
378 drag = QDrag(self) |
378 drag = QDrag(self) |
379 drag.setMimeData(self.__model.mimeData([idx])) |
379 drag.setMimeData(self.__model.mimeData([idx])) |
380 actionRect = self.actionGeometry(act) |
380 actionRect = self.actionGeometry(act) |
381 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
381 if qVersion() >= "5.0.0": |
|
382 drag.setPixmap(self.grab(actionRect)) |
|
383 else: |
|
384 drag.setPixmap(QPixmap.grabWidget(self, actionRect)) |
382 |
385 |
383 if drag.exec_() == Qt.MoveAction: |
386 if drag.exec_() == Qt.MoveAction: |
384 row = idx.row() |
387 row = idx.row() |
385 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
388 if self.__dropIndex == idx.parent() and self.__dropRow <= row: |
386 row += 1 |
389 row += 1 |