# eric4.E4Gui.E4ModelMenu

Module implementing a menu populated from a QAbstractItemModel.

### Global Attributes

None

### Classes

E4ModelMenu | Class implementing a menu populated from a QAbstractItemModel.

### Functions

None

## E4ModelMenu

Class implementing a menu populated from a QAbstractItemModel.

### Signals

activated(const QModelIndex&)
  emitted when an action has been triggered

### Derived from

QMenu

### Class Attributes

None

### Class Methods

None

### Methods

E4ModelMenu | Constructor
__aboutToShow | Private slot to show the menu.
__actionTriggered | Private slot to handle the triggering of an action.
__makeAction | Private method to create an action.
createBaseMenu | Public method to get the menu that is used to populate sub menu's.
createMenu | Public method to put all the children of a parent into a menu of a given length.
dragEnterEvent | Protected method to handle drag enter events.
dropEvent | Protected method to handle drop events.
firstSeparator | Public method to get the first separator.
index | Public method to get the index of an action.
makeAction | Public method to create an action.
maxRows | Public method to get the maximum number of entries to show.
model | Public method to get a reference to the model.
mouseMoveEvent | Protected method to handle mouse move events.
mousePressEvent | Protected method handling mouse press events.
mouseReleaseEvent | Protected method handling mouse release events.
postPopulated | Public method to add any actions after the tree.
prePopulated | Public method to add any actions before the tree.
removeEntry | Public method to remove a menu entry.
resetFlags | Public method to reset the saved internal state.
rootIndex | Public method to get the index of the root item.
separatorRole | Public method to get the role of the separator.
setFirstSeparator | Public method to set the first separator.
setMaxRows | Public method to set the maximum number of entries to show.
setModel | Public method to set the model for the menu.
setRootIndex | Public method to set the index of the root item.
setSeparatorRole | Public method to set the role of the separator.
setStatusBarTextRole | Public method to set the role of the status bar text.
statusBarTextRole | Public method to get the role of the status bar text.

### Static Methods

None

#### E4ModelMenu (Constructor)

E4ModelMenu(parent = None)

Constructor

parent
  reference to the parent widget (QWidget)

#### E4ModelMenu.__aboutToShow

__aboutToShow()

Private slot to show the menu.

#### E4ModelMenu.__actionTriggered

__actionTriggered(action)

Private slot to handle the triggering of an action.

action
  reference to the action that was triggered (QAction)

#### E4ModelMenu.__makeAction

__makeAction(idx)

Private method to create an action.

idx
  index of the item to create an action for (QModelIndex)

Returns:
  reference to the created action (QAction)

#### E4ModelMenu.createBaseMenu

createBaseMenu()

Public method to get the menu that is used to populate sub menu's.

Returns:
  reference to the menu (E4ModelMenu)

#### E4ModelMenu.createMenu

createMenu(parent, max_, parentMenu = None, menu = None)

Public method to put all the children of a parent into a menu of a given length.

parent
  index of the parent item (QModelIndex)
max_
  maximum number of entries (integer)
parentMenu
  reference to the parent menu (QMenu)
menu
  reference to the menu to be populated (QMenu)

#### E4ModelMenu.dragEnterEvent

dragEnterEvent(evt)

Protected method to handle drag enter events.

evt
  reference to the event (QDragEnterEvent)

#### E4ModelMenu.dropEvent

dropEvent(evt)

Protected method to handle drop events.

evt
  reference to the event (QDropEvent)

#### E4ModelMenu.firstSeparator

firstSeparator()

Public method to get the first separator.

Returns:
  row number of the first separator (integer)

#### E4ModelMenu.index

index(action)

Public method to get the index of an action.

action
  reference to the action to get the index for (QAction)

Returns:
  index of the action (QModelIndex)

#### E4ModelMenu.makeAction

makeAction(icon, text, parent)

Public method to create an action.

icon
  icon of the action (QIcon)
text
  text of the action (QString)
reference
  to the parent object (QObject)

Returns:
  reference to the created action (QAction)

#### E4ModelMenu.maxRows

maxRows()

Public method to get the maximum number of entries to show.

Returns:
  maximum number of entries to show (integer)

#### E4ModelMenu.model

model()

Public method to get a reference to the model.

Returns:
  reference to the model (QAbstractItemModel)

#### E4ModelMenu.mouseMoveEvent

mouseMoveEvent(evt)

Protected method to handle mouse move events.

evt
  reference to the event (QMouseEvent)

#### E4ModelMenu.mousePressEvent

mousePressEvent(evt)

Protected method handling mouse press events.

evt
  reference to the event object (QMouseEvent)

#### E4ModelMenu.mouseReleaseEvent

mouseReleaseEvent(evt)

Protected method handling mouse release events.

evt
  reference to the event object (QMouseEvent)

#### E4ModelMenu.postPopulated

postPopulated()

Public method to add any actions after the tree.

#### E4ModelMenu.prePopulated

prePopulated()

Public method to add any actions before the tree.

Returns:
  flag indicating if any actions were added

#### E4ModelMenu.removeEntry

removeEntry(idx)

Public method to remove a menu entry.

idx
  index of the entry to be removed (QModelIndex)

#### E4ModelMenu.resetFlags

resetFlags()

Public method to reset the saved internal state.

#### E4ModelMenu.rootIndex

rootIndex()

Public method to get the index of the root item.

Returns:
  index of the root item (QModelIndex)

#### E4ModelMenu.separatorRole

separatorRole()

Public method to get the role of the separator.

Returns:
  role of the separator (integer)

#### E4ModelMenu.setFirstSeparator

setFirstSeparator(offset)

Public method to set the first separator.

offset
  row number of the first separator (integer)

#### E4ModelMenu.setMaxRows

setMaxRows(rows)

Public method to set the maximum number of entries to show.

rows
  maximum number of entries to show (integer)

#### E4ModelMenu.setModel

setModel(model)

Public method to set the model for the menu.

model
  reference to the model (QAbstractItemModel)

#### E4ModelMenu.setRootIndex

setRootIndex(index)

Public method to set the index of the root item.

index
  index of the root item (QModelIndex)

#### E4ModelMenu.setSeparatorRole

setSeparatorRole(role)

Public method to set the role of the separator.

role
  role of the separator (integer)

#### E4ModelMenu.setStatusBarTextRole

setStatusBarTextRole(role)

Public method to set the role of the status bar text.

role
  role of the status bar text (integer)

#### E4ModelMenu.statusBarTextRole

statusBarTextRole()

Public method to get the role of the status bar text.

Returns:
  role of the status bar text (integer)

Up