eric7/E5Gui/E5ModelMenu.py

branch
eric7
changeset 8318
962bce857696
parent 8312
800c432b34c8
child 8319
ea11a3948f40
equal deleted inserted replaced
8316:0c7a44af84bc 8318:962bce857696
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 PyQt5.QtCore import pyqtSignal, Qt, QModelIndex, QPoint 10 from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint
11 from PyQt5.QtGui import QFontMetrics, QDrag 11 from PyQt6.QtGui import QFontMetrics, QDrag, QAction
12 from PyQt5.QtWidgets import QMenu, QAction, QApplication 12 from PyQt6.QtWidgets import QMenu, QApplication
13 13
14 import UI.PixmapCache 14 import UI.PixmapCache
15 15
16 16
17 class E5ModelMenu(QMenu): 17 class E5ModelMenu(QMenu):
324 Protected method to handle drop events. 324 Protected method to handle drop events.
325 325
326 @param evt reference to the event (QDropEvent) 326 @param evt reference to the event (QDropEvent)
327 """ 327 """
328 if self.__model is not None: 328 if self.__model is not None:
329 act = self.actionAt(evt.pos()) 329 act = self.actionAt(evt.position().toPoint())
330 parentIndex = self.__root 330 parentIndex = self.__root
331 if act is None: 331 if act is None:
332 row = self.__model.rowCount(self.__root) 332 row = self.__model.rowCount(self.__root)
333 else: 333 else:
334 idx = self.index(act) 334 idx = self.index(act)
355 Protected method handling mouse press events. 355 Protected method handling mouse press events.
356 356
357 @param evt reference to the event object (QMouseEvent) 357 @param evt reference to the event object (QMouseEvent)
358 """ 358 """
359 if evt.button() == Qt.MouseButton.LeftButton: 359 if evt.button() == Qt.MouseButton.LeftButton:
360 self.__dragStartPosition = evt.pos() 360 self.__dragStartPosition = evt.position().toPoint()
361 super().mousePressEvent(evt) 361 super().mousePressEvent(evt)
362 362
363 def mouseMoveEvent(self, evt): 363 def mouseMoveEvent(self, evt):
364 """ 364 """
365 Protected method to handle mouse move events. 365 Protected method to handle mouse move events.
376 376
377 if self.__dragStartPosition.isNull(): 377 if self.__dragStartPosition.isNull():
378 super().mouseMoveEvent(evt) 378 super().mouseMoveEvent(evt)
379 return 379 return
380 380
381 manhattanLength = (evt.pos() - 381 manhattanLength = (evt.position().toPoint() -
382 self.__dragStartPosition).manhattanLength() 382 self.__dragStartPosition).manhattanLength()
383 if manhattanLength <= QApplication.startDragDistance(): 383 if manhattanLength <= QApplication.startDragDistance():
384 super().mouseMoveEvent(evt) 384 super().mouseMoveEvent(evt)
385 return 385 return
386 386

eric ide

mercurial