E5Gui/E5ModelMenu.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
10 from PyQt4.QtCore import * 10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import * 11 from PyQt4.QtGui import *
12 12
13 import UI.PixmapCache 13 import UI.PixmapCache
14 14
15
15 class E5ModelMenu(QMenu): 16 class E5ModelMenu(QMenu):
16 """ 17 """
17 Class implementing a menu populated from a QAbstractItemModel. 18 Class implementing a menu populated from a QAbstractItemModel.
18 19
19 @signal activated(QModelIndex) emitted when an action has been triggered 20 @signal activated(QModelIndex) emitted when an action has been triggered
20 """ 21 """
21 activated = pyqtSignal(QModelIndex) 22 activated = pyqtSignal(QModelIndex)
22 23
23 def __init__(self, parent = None): 24 def __init__(self, parent=None):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param parent reference to the parent widget (QWidget) 28 @param parent reference to the parent widget (QWidget)
28 """ 29 """
177 178
178 @return reference to the menu (E5ModelMenu) 179 @return reference to the menu (E5ModelMenu)
179 """ 180 """
180 return E5ModelMenu(self) 181 return E5ModelMenu(self)
181 182
182 def createMenu(self, parent, max_, parentMenu = None, menu = None): 183 def createMenu(self, parent, max_, parentMenu=None, menu=None):
183 """ 184 """
184 Public method to put all the children of a parent into a menu of a given length. 185 Public method to put all the children of a parent into a menu of a given length.
185 186
186 @param parent index of the parent item (QModelIndex) 187 @param parent index of the parent item (QModelIndex)
187 @param max_ maximum number of entries (integer) 188 @param max_ maximum number of entries (integer)
327 row = self.__model.rowCount(idx) 328 row = self.__model.rowCount(idx)
328 329
329 self.__dropRow = row 330 self.__dropRow = row
330 self.__dropIndex = parentIndex 331 self.__dropIndex = parentIndex
331 evt.acceptProposedAction() 332 evt.acceptProposedAction()
332 self.__model.dropMimeData(evt.mimeData(), evt.dropAction(), 333 self.__model.dropMimeData(evt.mimeData(), evt.dropAction(),
333 row, 0, parentIndex) 334 row, 0, parentIndex)
334 self.close() 335 self.close()
335 336
336 QMenu.dropEvent(self, evt) 337 QMenu.dropEvent(self, evt)
337 338

eric ide

mercurial