Updraft  1.0
Open source glider flight visualisation tool.
Updraft::Core::Menu Class Reference

Wrapper around QMenu that can work with item priorities. More...

#include <menu.h>

Inheritance diagram for Updraft::Core::Menu:
Collaboration diagram for Updraft::Core::Menu:

List of all members.

Public Member Functions

 Menu (QMenu *setMenu, bool ownsQMenu)
 Constructor.
 ~Menu ()
void lightClear ()
 Clears the actions from the menu, but does not destroy the owned actions.
void clear ()
 Clears the whole menu and destroys the owned actions.
void insertAction (int position, QAction *action, bool own=false)
 Insert action into this menu.
void appendAction (QAction *action, bool own=false)
 Appends an action into the menu.
QMenu * getQMenu ()
 Gets the QMenu wrapped by this menu.
QMenu * giveQMenu ()
 Returns the contained QMenu and creates a new empty one.

Private Member Functions

void reorganizeMenu ()
 Called upon insertion or removal of an action.

Private Attributes

QMenu * menu
bool ownsMenu
QMultiMap< int, QAction * > actions
 All the actions sorted by priority. Used for inserting a new action.
QList< QAction * > ownedActions
 Actions that this menu owns and should be erased when the menu is erased.

Detailed Description

Wrapper around QMenu that can work with item priorities.


Constructor & Destructor Documentation

Updraft::Core::Menu::Menu ( QMenu *  setMenu,
bool  ownsQMenu 
) [inline]

Constructor.

Parameters:
setMenuThe QMenu with which the menu is initialized
ownsQMenuWhether the QMenu passed to this constructor should be destoryed when the Menu instance is destroyed. Default: false

Member Function Documentation

void Updraft::Core::Menu::appendAction ( QAction *  action,
bool  own = false 
) [virtual]

Appends an action into the menu.

Parameters:
actionThe action to be appended
ownWhether the action's ownership should transfer to the menu. If true, the menu destroys the QAction when it is no longer needed.

Implements Updraft::MenuInterface.

Clears the whole menu and destroys the owned actions.

Reimplemented from Updraft::MenuInterface.

QMenu* Updraft::Core::Menu::getQMenu ( ) [inline]

Gets the QMenu wrapped by this menu.

Returns:
The QMenu wrapped by this menu

Returns the contained QMenu and creates a new empty one.

The ownership of the menu is transferred to the caller.

void Updraft::Core::Menu::insertAction ( int  position,
QAction *  action,
bool  own = false 
) [virtual]

Insert action into this menu.

Parameters:
positionPriority of this action. Actions with lower value are closer to the top.
actionThe action to be inserted
ownWhether the action's ownership should transfer to the menu. If true, the menu destroys the QAction when it is no longer needed.

Implements Updraft::MenuInterface.

Clears the actions from the menu, but does not destroy the owned actions.

Called upon insertion or removal of an action.


Member Data Documentation

QMultiMap<int, QAction*> Updraft::Core::Menu::actions [private]

All the actions sorted by priority. Used for inserting a new action.

QMenu* Updraft::Core::Menu::menu [private]
QList<QAction*> Updraft::Core::Menu::ownedActions [private]

Actions that this menu owns and should be erased when the menu is erased.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines