9 |
9 |
10 from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint |
10 from PyQt6.QtCore import pyqtSignal, Qt, QModelIndex, QPoint |
11 from PyQt6.QtGui import QFontMetrics, QDrag, QAction |
11 from PyQt6.QtGui import QFontMetrics, QDrag, QAction |
12 from PyQt6.QtWidgets import QMenu, QApplication |
12 from PyQt6.QtWidgets import QMenu, QApplication |
13 |
13 |
14 import UI.PixmapCache |
14 from eric7.EricGui import EricPixmapCache |
15 |
15 |
16 |
16 |
17 class EricModelMenu(QMenu): |
17 class EricModelMenu(QMenu): |
18 """ |
18 """ |
19 Class implementing a menu populated from a QAbstractItemModel. |
19 Class implementing a menu populated from a QAbstractItemModel. |
213 modelMenu.triggered.disconnect(modelMenu.__actionTriggered) |
213 modelMenu.triggered.disconnect(modelMenu.__actionTriggered) |
214 modelMenu.setTitle(title) |
214 modelMenu.setTitle(title) |
215 |
215 |
216 icon = parent.data(Qt.ItemDataRole.DecorationRole) |
216 icon = parent.data(Qt.ItemDataRole.DecorationRole) |
217 if icon == NotImplemented or icon is None: |
217 if icon == NotImplemented or icon is None: |
218 icon = UI.PixmapCache.getIcon("defaultIcon") |
218 icon = EricPixmapCache.getIcon("defaultIcon") |
219 modelMenu.setIcon(icon) |
219 modelMenu.setIcon(icon) |
220 if parentMenu is not None: |
220 if parentMenu is not None: |
221 self.menuActions.append(parentMenu.addMenu(modelMenu).setData(v)) |
221 self.menuActions.append(parentMenu.addMenu(modelMenu).setData(v)) |
222 modelMenu.setRootIndex(parent) |
222 modelMenu.setRootIndex(parent) |
223 modelMenu.setModel(self.__model) |
223 modelMenu.setModel(self.__model) |
250 @param idx index of the item to create an action for (QModelIndex) |
250 @param idx index of the item to create an action for (QModelIndex) |
251 @return reference to the created action (QAction) |
251 @return reference to the created action (QAction) |
252 """ |
252 """ |
253 icon = idx.data(Qt.ItemDataRole.DecorationRole) |
253 icon = idx.data(Qt.ItemDataRole.DecorationRole) |
254 if icon == NotImplemented or icon is None: |
254 if icon == NotImplemented or icon is None: |
255 icon = UI.PixmapCache.getIcon("defaultIcon") |
255 icon = EricPixmapCache.getIcon("defaultIcon") |
256 action = self.makeAction(icon, idx.data(), self) |
256 action = self.makeAction(icon, idx.data(), self) |
257 action.setStatusTip(idx.data(self.__statusBarTextRole)) |
257 action.setStatusTip(idx.data(self.__statusBarTextRole)) |
258 |
258 |
259 v = idx |
259 v = idx |
260 action.setData(v) |
260 action.setData(v) |