eric7/EricWidgets/EricModelMenu.py

branch
eric7
changeset 8420
ff89f8bac0a5
parent 8358
144a6b854f70
child 8881
54e42bc2437a
equal deleted inserted replaced
8419:32506bc52886 8420:ff89f8bac0a5
44 self._mouseButton = Qt.MouseButton.NoButton 44 self._mouseButton = Qt.MouseButton.NoButton
45 self._keyboardModifiers = Qt.KeyboardModifier.NoModifier 45 self._keyboardModifiers = Qt.KeyboardModifier.NoModifier
46 self.__dropRow = -1 46 self.__dropRow = -1
47 self.__dropIndex = None 47 self.__dropIndex = None
48 48
49 self.menuActions = []
50
49 # This is to ensure it will be shown on Mac OS X 51 # This is to ensure it will be shown on Mac OS X
50 self.addAction("--not populated--") 52 self.addAction("--not populated--")
51 53
52 self.aboutToShow.connect(self.__aboutToShow) 54 self.aboutToShow.connect(self.__aboutToShow)
53 self.triggered.connect(self.__actionTriggered) 55 self.triggered.connect(self.__actionTriggered)
56
57 def clear(self):
58 """
59 Public method to clear the menu.
60 """
61 super().clear()
62 self.menuActions.clear()
54 63
55 def prePopulated(self): 64 def prePopulated(self):
56 """ 65 """
57 Public method to add any actions before the tree. 66 Public method to add any actions before the tree.
58 67
206 icon = parent.data(Qt.ItemDataRole.DecorationRole) 215 icon = parent.data(Qt.ItemDataRole.DecorationRole)
207 if icon == NotImplemented or icon is None: 216 if icon == NotImplemented or icon is None:
208 icon = UI.PixmapCache.getIcon("defaultIcon") 217 icon = UI.PixmapCache.getIcon("defaultIcon")
209 modelMenu.setIcon(icon) 218 modelMenu.setIcon(icon)
210 if parentMenu is not None: 219 if parentMenu is not None:
211 parentMenu.addMenu(modelMenu).setData(v) 220 self.menuActions.append(
221 parentMenu.addMenu(modelMenu).setData(v))
212 modelMenu.setRootIndex(parent) 222 modelMenu.setRootIndex(parent)
213 modelMenu.setModel(self.__model) 223 modelMenu.setModel(self.__model)
214 return 224 return
215 225
216 if self.__model is None: 226 if self.__model is None:

eric ide

mercurial