Updraft
1.0
Open source glider flight visualisation tool.
|
Wrapper around QMenu that can work with item priorities. More...
#include <menu.h>
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. |
Wrapper around QMenu that can work with item priorities.
Updraft::Core::Menu::Menu | ( | QMenu * | setMenu, |
bool | ownsQMenu | ||
) | [inline] |
Constructor.
setMenu | The QMenu with which the menu is initialized |
ownsQMenu | Whether the QMenu passed to this constructor should be destoryed when the Menu instance is destroyed. Default: false |
void Updraft::Core::Menu::appendAction | ( | QAction * | action, |
bool | own = false |
||
) | [virtual] |
Appends an action into the menu.
action | The action to be appended |
own | Whether 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.
void Updraft::Core::Menu::clear | ( | ) |
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.
QMenu * Updraft::Core::Menu::giveQMenu | ( | ) |
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.
position | Priority of this action. Actions with lower value are closer to the top. |
action | The action to be inserted |
own | Whether 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.
void Updraft::Core::Menu::lightClear | ( | ) |
Clears the actions from the menu, but does not destroy the owned actions.
void Updraft::Core::Menu::reorganizeMenu | ( | ) | [private] |
Called upon insertion or removal of an action.
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.
bool Updraft::Core::Menu::ownsMenu [private] |