eric7/E5Gui/E5ModelToolBar.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 tool bar populated from a QAbstractItemModel. 7 Module implementing a tool bar populated from a QAbstractItemModel.
8 """ 8 """
9 9
10 from PyQt5.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent 10 from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint, QEvent
11 from PyQt5.QtGui import QDrag, QIcon 11 from PyQt6.QtGui import QDrag, QIcon
12 from PyQt5.QtWidgets import QApplication, QToolBar, QToolButton 12 from PyQt6.QtWidgets import QApplication, QToolBar, QToolButton
13 13
14 14
15 class E5ModelToolBar(QToolBar): 15 class E5ModelToolBar(QToolBar):
16 """ 16 """
17 Class implementing a tool bar populated from a QAbstractItemModel. 17 Class implementing a tool bar populated from a QAbstractItemModel.
124 124
125 if folder: 125 if folder:
126 menu = self._createMenu() 126 menu = self._createMenu()
127 menu.setModel(self.__model) 127 menu.setModel(self.__model)
128 menu.setRootIndex(idx) 128 menu.setRootIndex(idx)
129 act.setMenu(menu) 129 button.setMenu(menu)
130 button.setPopupMode( 130 button.setPopupMode(
131 QToolButton.ToolButtonPopupMode.InstantPopup) 131 QToolButton.ToolButtonPopupMode.InstantPopup)
132 button.setToolButtonStyle( 132 button.setToolButtonStyle(
133 Qt.ToolButtonStyle.ToolButtonTextBesideIcon) 133 Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
134 134
203 203
204 @param evt reference to the event (QDropEvent) 204 @param evt reference to the event (QDropEvent)
205 @exception RuntimeError raised to indicate an invalid model index 205 @exception RuntimeError raised to indicate an invalid model index
206 """ 206 """
207 if self.__model is not None: 207 if self.__model is not None:
208 act = self.actionAt(evt.pos()) 208 act = self.actionAt(evt.position().toPoint())
209 parentIndex = self.__root 209 parentIndex = self.__root
210 if act is None: 210 if act is None:
211 row = self.__model.rowCount(self.__root) 211 row = self.__model.rowCount(self.__root)
212 else: 212 else:
213 idx = self.index(act) 213 idx = self.index(act)
239 239
240 if not (evt.buttons() & Qt.MouseButton.LeftButton): 240 if not (evt.buttons() & Qt.MouseButton.LeftButton):
241 super().mouseMoveEvent(evt) 241 super().mouseMoveEvent(evt)
242 return 242 return
243 243
244 manhattanLength = (evt.pos() - 244 manhattanLength = (evt.position().toPoint() -
245 self.__dragStartPosition).manhattanLength() 245 self.__dragStartPosition).manhattanLength()
246 if manhattanLength <= QApplication.startDragDistance(): 246 if manhattanLength <= QApplication.startDragDistance():
247 super().mouseMoveEvent(evt) 247 super().mouseMoveEvent(evt)
248 return 248 return
249 249

eric ide

mercurial