Version: 9.12.0
QtxActionMenuMgr Class Reference

Main menu actions manager. More...

#include <QtxActionMenuMgr.h>

Inheritance diagram for QtxActionMenuMgr:
Inheritance graph

Classes

class  MenuCreator
 Menu actions creator. More...
 
class  MenuNode
 Represents a menu item inside main menu structure. More...
 

Signals

void menuAboutToShow (QMenu *)
 Emitted when the menu is about to be shown. More...
 
void menuAboutToHide (QMenu *)
 Emitted when the menu is about to be hidden. More...
 

Public Member Functions

 QtxActionMenuMgr (QMainWindow *)
 Constructor. More...
 
 QtxActionMenuMgr (QWidget *, QObject *)
 Constructor. More...
 
virtual ~QtxActionMenuMgr ()
 Destructor. More...
 
QWidgetmenuWidget () const
 Get the menu widget. More...
 
virtual bool isVisible (const int, const int) const
 Check if an action with actId identifier is visible to the parent action with place identifier. More...
 
virtual void setVisible (const int, const int, const bool)
 Set action's visibility flag. More...
 
int insert (const int, const QString &, const int, const int=-1)
 Insert action to the menu. More...
 
int insert (QAction *, const QString &, const int, const int=-1)
 Insert action to the menu. More...
 
int insert (const int, const QStringList &, const int, const int=-1)
 Insert action to the menu. More...
 
int insert (QAction *, const QStringList &, const int, const int=-1)
 Insert action to the menu. More...
 
virtual int insert (const int, const int, const int, const int=-1)
 Insert action to the menu. More...
 
int insert (QAction *, const int, const int, const int=-1)
 Insert action to the menu. More...
 
int insert (const QString &, const QString &, const int, const int=-1, const int=-1)
 Create and insert menu item action to the menu. More...
 
int insert (const QString &, const QStringList &, const int, const int=-1, const int=-1)
 Create and insert menu item action to the menu. More...
 
virtual int insert (const QString &, const int, const int, const int=-1, const int=-1, QMenu *=0)
 Create and insert menu item action to the menu. More...
 
int append (const int, const int, const int)
 Create and add menu item action to the end of menu. More...
 
int append (QAction *, const int, const int)
 Create and add menu item action to the end of menu. More...
 
int append (const QString &, const int, const int, const int=-1)
 Create and add menu item action to the end of menu. More...
 
int prepend (const int, const int, const int)
 Create and add menu item action to the beginning of menu. More...
 
int prepend (QAction *, const int, const int)
 Create and add menu item action to the beginning of menu. More...
 
int prepend (const QString &, const int, const int, const int=-1)
 Create and add menu item action to the beginning of menu. More...
 
void remove (const int)
 Remove menu item with given id. More...
 
void remove (const int, const int, const int=-1)
 Remove menu item with given id. More...
 
void show (const int)
 Show menu item with given id. More...
 
void hide (const int)
 Hide menu item with given id. More...
 
bool isShown (const int) const
 Get visibility status for menu item with given id. More...
 
void setShown (const int, const bool)
 Set visibility status for menu item with given id. More...
 
virtual void change (const int, const QString &)
 Change menu title for the action with given id. More...
 
virtual bool load (const QString &, QtxActionMgr::Reader &)
 Load actions description from the file. More...
 
bool containsMenu (const QString &, const int, const bool=false) const
 Check if the parent menu contains menu item with given title. More...
 
bool containsMenu (const int, const int, const bool=false) const
 Check if the parent menu contains menu item with given id. More...
 
QMenufindMenu (const int) const
 Get menu by the specified identifier. More...
 
QMenufindMenu (const QString &, const int, const bool=false) const
 Get menu by the title. More...
 
bool isEmptyEnabled (const int) const
 Check if empty menu is enabled. More...
 
void setEmptyEnabled (const int, const bool)
 Enable/disable empty menu. More...
 
- Public Member Functions inherited from QtxActionMgr
 QtxActionMgr (QObject *parent)
 Constructor. More...
 
virtual ~QtxActionMgr ()
 Destructor. More...
 
virtual int registerAction (QAction *, const int=-1)
 Register an action in the internal map. More...
 
virtual void unRegisterAction (const int)
 Unregister action from internal map. More...
 
QActionaction (const int) const
 Get action by specified identifier. More...
 
int actionId (const QAction *) const
 Get action identifier. More...
 
bool contains (const int) const
 Check if an action with given id is registered in the action manager. More...
 
int count () const
 Get total number of registered actions. More...
 
bool isEmpty () const
 Check if there are no actions registered in the action manager. More...
 
QIntList idList () const
 Get all registered actions identifiers. More...
 
bool isUpdatesEnabled () const
 Check if update is enabled. More...
 
virtual void setUpdatesEnabled (const bool)
 Enable/disable update operation. More...
 
void update ()
 Update actions. More...
 
virtual bool isEnabled (const int) const
 Check is action with given id is enabled. More...
 
virtual void setEnabled (const int, const bool)
 

Protected Member Functions

void setMenuWidget (QWidget *)
 Assign new menu widget to the menu manager. More...
 
MenuNodefind (const int, const int, const bool=true) const
 Search menu node. More...
 
MenuNodefind (const int, MenuNode *=0, const bool=true) const
 Search menu node. More...
 
bool find (const int, NodeList &, MenuNode *=0) const
 Search recursively all menu nodes with given id. More...
 
MenuNodefind (const QString &, const int, const bool=true) const
 Search menu node. More...
 
MenuNodefind (const QString &, MenuNode *=0, const bool=true) const
 Search menu node. More...
 
bool find (const QString &, NodeList &, MenuNode *=0) const
 Search recursively all menu nodes with given title. More...
 
int findId (const int, const int=-1) const
 Find menu item by given ID (one-level only). More...
 
void removeMenu (const int, MenuNode *)
 Removes menu node (with all its children). More...
 
QActionitemAction (const int) const
 Get action by id. More...
 
QActionmenuAction (const int) const
 Get submenu action by id. More...
 
int menuActionId (QAction *) const
 Get submenu action by id. More...
 
void updateMenu (MenuNode *=0, const bool=true, const bool=true)
 Update menu. More...
 
virtual void internalUpdate ()
 Internal update. More...
 
virtual void updateContent ()
 Called when delayed content update is performed. More...
 
virtual void actionChanged (int)
 Called when action is changed. More...
 
- Protected Member Functions inherited from QtxActionMgr
int generateId () const
 Generate unique action identifier. More...
 
void triggerUpdate ()
 Perform delayed update. More...
 

Private Types

typedef QList< MenuNode * > NodeList
 menu nodes list More...
 
typedef QMap< int, QAction * > MenuMap
 actions map More...
 

Private Slots

void onAboutToShow ()
 Called when the submenu is about to show. More...
 
void onAboutToHide ()
 Called when the submenu is about to hide. More...
 
void onDestroyed (QObject *)
 Called when the corresponding menu object is destroyed. More...
 

Private Member Functions

bool ownAction (QAction *, MenuNode *) const
 Check if action belongs to the menu manager. More...
 
bool checkWidget (QWidget *) const
 Check if menu widget has any actions. More...
 
QWidgetmenuWidget (MenuNode *) const
 Get menu widget for the given node. More...
 
void simplifySeparators (QWidget *)
 Remove extra separators from menu widget. More...
 
QString clearTitle (const QString &) const
 Remove special symbols (&) from string to get clear menu title. More...
 
int createMenu (const QStringList &, const int)
 Create and inserts menu item recursively. More...
 
void triggerUpdate (const int, const bool rec=true)
 Perform delayed menu update. More...
 

Private Attributes

MenuNodemyRoot
 root menu node More...
 
QWidgetmyMenu
 menu widget More...
 
MenuMap myMenus
 actions map More...
 
QMap< int, bool > myUpdateIds
 list of actions ID being updated More...
 

Additional Inherited Members

- Static Public Member Functions inherited from QtxActionMgr
static QActionseparator (const bool=false)
 Create new separator action. More...
 

Detailed Description

Main menu actions manager.

Menu manager allows using of set of action for automatic generating of application main menu and dynamic update of its contents.

Use insert(), append() and remove() methods to create main menu. Methods show(), hide() allow displaying/erasing of specified menu items.

Actions can be grouped with help of group identificator. Inside the popup or main menu bar menu items are ordered by the group identifier (ascending).

Menu manager automatically optimizes the menu by removing extra separators, hiding empty popup menus etc.

Member Typedef Documentation

◆ MenuMap

typedef QMap<int, QAction*> QtxActionMenuMgr::MenuMap
private

actions map

◆ NodeList

menu nodes list

Constructor & Destructor Documentation

◆ QtxActionMenuMgr() [1/2]

QtxActionMenuMgr::QtxActionMenuMgr ( QMainWindow p)

Constructor.

Parameters
pparent main window

References myMenu, and onDestroyed().

◆ QtxActionMenuMgr() [2/2]

QtxActionMenuMgr::QtxActionMenuMgr ( QWidget mw,
QObject p 
)

Constructor.

Parameters
mwmenu widget
pparent object

References myMenu, and onDestroyed().

◆ ~QtxActionMenuMgr()

QtxActionMenuMgr::~QtxActionMenuMgr ( )
virtual

Destructor.

References myMenus, and myRoot.

Member Function Documentation

◆ actionChanged()

void QtxActionMenuMgr::actionChanged ( int  id)
protectedvirtual

Called when action is changed.

Schedule delayed update for parent menu of changed action.

Reimplemented from QtxActionMgr.

References find(), QtxActionMenuMgr::MenuNode::id, myRoot, QtxActionMenuMgr::MenuNode::parent, QtxActionMgr::triggerUpdate(), and QtxActionMenuMgr::MenuNode::visible.

◆ append() [1/3]

int QtxActionMenuMgr::append ( const int  id,
const int  pId,
const int  group 
)

Create and add menu item action to the end of menu.

Parameters
idaction ID
pIdparent menu action ID
groupgroup ID
Returns
action ID

References insert().

◆ append() [2/3]

int QtxActionMenuMgr::append ( const QString &  title,
const int  pId,
const int  group,
const int  id = -1 
)

Create and add menu item action to the end of menu.

Parameters
titlemenu text
pIdparent menu action ID
groupgroup ID
idaction ID
Returns
action ID

References insert().

◆ append() [3/3]

int QtxActionMenuMgr::append ( QAction a,
const int  pId,
const int  group 
)

Create and add menu item action to the end of menu.

Parameters
aaction
pIdparent menu action ID
groupgroup ID
Returns
action ID

References insert().

◆ change()

void QtxActionMenuMgr::change ( const int  id,
const QString &  title 
)
virtual

Change menu title for the action with given id.

Parameters
idmenu action ID
titlenew menu title

References menuAction().

◆ checkWidget()

bool QtxActionMenuMgr::checkWidget ( QWidget wid) const
private

Check if menu widget has any actions.

Parameters
widwidget to be checked
Returns
true if widget contains action(s)

◆ clearTitle()

QString QtxActionMenuMgr::clearTitle ( const QString &  txt) const
private

Remove special symbols (&) from string to get clear menu title.

Parameters
txtstring to be processed
Returns
clear title

◆ containsMenu() [1/2]

bool QtxActionMenuMgr::containsMenu ( const int  id,
const int  pid,
const bool  rec = false 
) const

Check if the parent menu contains menu item with given id.

Parameters
idmenu item ID
pidparent menu item ID
Returns
true if parent menu item contains such child item

References find().

◆ containsMenu() [2/2]

bool QtxActionMenuMgr::containsMenu ( const QString &  title,
const int  pid,
const bool  rec = false 
) const

Check if the parent menu contains menu item with given title.

Parameters
titlemenu title
pidparent menu item ID
Returns
true if parent menu item contains such child item

References find().

◆ createMenu()

int QtxActionMenuMgr::createMenu ( const QStringList &  lst,
const int  pId 
)
private

Create and inserts menu item recursively.

Parameters
lstlist of menu names
pIdparent menu item ID
Returns
created menu item ID (last in the chain)

References insert().

◆ find() [1/6]

QtxActionMenuMgr::MenuNode * QtxActionMenuMgr::find ( const int  id,
const int  pId,
const bool  rec = true 
) const
protected

Search menu node.

Parameters
idmenu action ID
pIdparent menu item ID
recif true perform recursive search
Returns
menu node or 0 if it is not found

◆ find() [2/6]

QtxActionMenuMgr::MenuNode * QtxActionMenuMgr::find ( const int  id,
MenuNode startNode = 0,
const bool  rec = true 
) const
protected

Search menu node.

Parameters
idmenu action ID
startNodestart menu node (if 0, search from root node)
recif true perform recursive search
Returns
menu node or 0 if it is not found

References QtxActionMenuMgr::MenuNode::children, find(), and myRoot.

◆ find() [3/6]

bool QtxActionMenuMgr::find ( const int  id,
NodeList lst,
MenuNode startNode = 0 
) const
protected

Search recursively all menu nodes with given id.

Parameters
idmenu action ID
NodeListresulting list of menu nodes
startNodestart menu node (if 0, search from root node)
Returns
true if at least one node is found

References QtxActionMenuMgr::MenuNode::children, find(), QtxActionMenuMgr::MenuNode::id, and myRoot.

◆ find() [4/6]

QtxActionMenuMgr::MenuNode * QtxActionMenuMgr::find ( const QString &  title,
const int  pId,
const bool  rec = true 
) const
protected

Search menu node.

Parameters
titlemenu item title
pIdparent menu item ID
recif true perform recursive search
Returns
menu node or 0 if it is not found

References find().

◆ find() [5/6]

QtxActionMenuMgr::MenuNode * QtxActionMenuMgr::find ( const QString &  title,
MenuNode startNode = 0,
const bool  rec = true 
) const
protected

Search menu node.

Parameters
titlemenu item title
startNodestart menu node (if 0, search from root node)
recif true perform recursive search
Returns
menu node or 0 if it is not found

References QtxActionMenuMgr::MenuNode::children, clearTitle(), find(), itemAction(), menuAction(), and myRoot.

◆ find() [6/6]

bool QtxActionMenuMgr::find ( const QString &  title,
NodeList lst,
MenuNode startNode = 0 
) const
protected

Search recursively all menu nodes with given title.

Parameters
titlemenu item title
NodeListresulting list of menu nodes
startNodestart menu node (if 0, search from root node)
Returns
true if at least one node is found

References QtxActionMenuMgr::MenuNode::children, clearTitle(), find(), itemAction(), menuAction(), and myRoot.

◆ findId()

int QtxActionMenuMgr::findId ( const int  id,
const int  pid = -1 
) const
protected

Find menu item by given ID (one-level only).

Parameters
idmenu action ID
pidparent meun item ID
Returns
id (>0) on success or -1 if menu item is not found

References QtxActionMenuMgr::MenuNode::children, find(), and myRoot.

◆ findMenu() [1/2]

QMenu * QtxActionMenuMgr::findMenu ( const int  id) const

Get menu by the specified identifier.

Parameters
idmenu item ID
Returns
menu pointer or 0 if menu is not found

References menuAction().

◆ findMenu() [2/2]

QMenu * QtxActionMenuMgr::findMenu ( const QString &  title,
const int  pid,
const bool  rec = false 
) const

Get menu by the title.

Parameters
titlemenu text
pidparent menu item ID (to start search)
recif true, perform recursive update
Returns
menu pointer or 0 if menu is not found

References find(), QtxActionMenuMgr::MenuNode::id, and menuAction().

◆ hide()

void QtxActionMenuMgr::hide ( const int  id)

Hide menu item with given id.

Parameters
idmenu action ID
See also
show()

References setShown().

◆ insert() [1/9]

int QtxActionMenuMgr::insert ( const int  id,
const int  pId,
const int  group,
const int  idx = -1 
)
virtual

Insert action to the menu.

Parameters
idaction ID
pIdparent menu action ID
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

References find(), QtxActionMenuMgr::MenuNode::id, myRoot, and QtxActionMgr::triggerUpdate().

◆ insert() [2/9]

int QtxActionMenuMgr::insert ( const int  id,
const QString &  menus,
const int  group,
const int  idx = -1 
)

Insert action to the menu.

Insert an action to the named menu. The menus parameter represents the menu name: it can be a sequence of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
idaction ID
menusmenu name
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

◆ insert() [3/9]

int QtxActionMenuMgr::insert ( const int  id,
const QStringList &  menus,
const int  group,
const int  idx = -1 
)

Insert action to the menu.

Insert an action to the named menu. The menus parameter represents the menu names list. For example, string list consisting from two items "File" and "Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
idaction ID
menusmenu names list
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

References createMenu(), and insert().

◆ insert() [4/9]

int QtxActionMenuMgr::insert ( const QString &  title,
const int  pId,
const int  group,
const int  id = -1,
const int  idx = -1,
QMenu _menu = 0 
)
virtual

Create and insert menu item action to the menu.

Parameters
titlemenu text
pIdparent menu action ID
groupgroup ID
idaction ID
idxmenu index inside the menu group
Returns
action ID

References QtxActionMenuMgr::MenuNode::children, clearTitle(), find(), QtxActionMgr::generateId(), QtxActionMenuMgr::MenuNode::id, myMenus, myRoot, onAboutToHide(), onAboutToShow(), and QtxActionMgr::triggerUpdate().

◆ insert() [5/9]

int QtxActionMenuMgr::insert ( const QString &  title,
const QString &  menus,
const int  group,
const int  id = -1,
const int  idx = -1 
)

Create and insert menu item action to the menu.

Insert an action to the named menu. The menus parameter represents the menu name: it can be a sequence of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
titlemenu text
menusmenu name
groupgroup ID
idaction ID
idxmenu index inside the menu group
Returns
action ID

References insert().

◆ insert() [6/9]

int QtxActionMenuMgr::insert ( const QString &  title,
const QStringList &  menus,
const int  group,
const int  id = -1,
const int  idx = -1 
)

Create and insert menu item action to the menu.

Insert an action to the named menu. The menus parameter represents the menu names list. For example, string list consisting from two items "File" and "Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
titlemenu text
menusmenu names list
groupgroup ID
idaction ID
idxmenu index inside the menu group
Returns
action ID

References createMenu(), and insert().

◆ insert() [7/9]

int QtxActionMenuMgr::insert ( QAction a,
const int  pId,
const int  group,
const int  idx = -1 
)

Insert action to the menu.

Parameters
aaction
pIdparent menu action ID
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

References insert(), and QtxActionMgr::registerAction().

◆ insert() [8/9]

int QtxActionMenuMgr::insert ( QAction a,
const QString &  menus,
const int  group,
const int  idx = -1 
)

Insert action to the menu.

Insert an action to the named menu. The menus parameter represents the menu name: it can be a sequence of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
aaction
menusmenu name
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

References insert().

◆ insert() [9/9]

int QtxActionMenuMgr::insert ( QAction a,
const QStringList &  menus,
const int  group,
const int  idx = -1 
)

Insert action to the menu.

Insert an action to the named menu. The menus parameter represents the menu names list. For example, string list consisting from two items "File" and "Edit" means File->Edit submenu. If submenu doesn't exist, it will be created.

Parameters
aaction
menusmenu names list
groupgroup ID
idxmenu index inside the menu group
Returns
action ID

References createMenu(), and insert().

◆ internalUpdate()

void QtxActionMenuMgr::internalUpdate ( )
protectedvirtual

Internal update.

Customizes the menu update processing.

Reimplemented from QtxActionMgr.

Reimplemented in QtxPopupMgr.

References QtxActionMgr::isUpdatesEnabled(), myUpdateIds, and updateMenu().

◆ isEmptyEnabled()

bool QtxActionMenuMgr::isEmptyEnabled ( const int  id) const

Check if empty menu is enabled.

Parameters
idmenu item ID
Returns
true if empty menu is enabled

References QtxActionMenuMgr::MenuNode::emptyEnabled, find(), and menuAction().

◆ isShown()

bool QtxActionMenuMgr::isShown ( const int  id) const

Get visibility status for menu item with given id.

Parameters
idmenu action ID
Returns
true if an item is shown
See also
setShown()

References find(), and QtxActionMenuMgr::MenuNode::visible.

◆ isVisible()

bool QtxActionMenuMgr::isVisible ( const int  actId,
const int  place 
) const
virtual

Check if an action with actId identifier is visible to the parent action with place identifier.

Parameters
actIdaction ID
placesome parent action ID
Returns
true if an action is visible to the parent
See also
setVisible()

Reimplemented from QtxActionMgr.

Reimplemented in QtxPopupMgr.

References find(), and QtxActionMenuMgr::MenuNode::visible.

◆ itemAction()

QAction * QtxActionMenuMgr::itemAction ( const int  id) const
protected

Get action by id.

Parameters
idaction ID
Returns
action or 0 if id is invalid

References QtxActionMgr::action().

◆ load()

bool QtxActionMenuMgr::load ( const QString &  fname,
QtxActionMgr::Reader r 
)
virtual

Load actions description from the file.

Parameters
fnamefile name
raction reader
Returns
true on success and false on error

Reimplemented in QtxPopupMgr.

References QtxActionMgr::Reader::read().

◆ menuAboutToHide

void QtxActionMenuMgr::menuAboutToHide ( QMenu m)
signal

Emitted when the menu is about to be hidden.

Parameters
mmenu being hidden

◆ menuAboutToShow

void QtxActionMenuMgr::menuAboutToShow ( QMenu m)
signal

Emitted when the menu is about to be shown.

Parameters
mmenu being shown

◆ menuAction()

QAction * QtxActionMenuMgr::menuAction ( const int  id) const
protected

Get submenu action by id.

Parameters
idsubmenu ID
Returns
submenu action or 0 if action is not found

References myMenus.

◆ menuActionId()

int QtxActionMenuMgr::menuActionId ( QAction a) const
protected

Get submenu action by id.

Parameters
idsubmenu ID
Returns
submenu action or 0 if it is not found

References myMenus.

◆ menuWidget() [1/2]

QWidget * QtxActionMenuMgr::menuWidget ( ) const

Get the menu widget.

Returns
menu widget (QMenuBar)

References myMenu.

◆ menuWidget() [2/2]

QWidget * QtxActionMenuMgr::menuWidget ( MenuNode node) const
private

Get menu widget for the given node.

Parameters
nodemenu node
Returns
popup menu or main menu corresponding to the menu node (or 0 if it is not found)

References QtxActionMenuMgr::MenuNode::id, myMenu, myMenus, and myRoot.

◆ onAboutToHide

void QtxActionMenuMgr::onAboutToHide ( )
privateslot

Called when the submenu is about to hide.

Emits the signal menuAboutToHide(QMenu*).

References menuAboutToHide().

◆ onAboutToShow

void QtxActionMenuMgr::onAboutToShow ( )
privateslot

Called when the submenu is about to show.

Emits the signal menuAboutToShow(QMenu*).

References menuAboutToShow().

◆ onDestroyed

void QtxActionMenuMgr::onDestroyed ( QObject obj)
privateslot

Called when the corresponding menu object is destroyed.

Clears internal pointer to menu to disable crashes.

Parameters
obj(menu) object being destroyed

References myMenu.

◆ ownAction()

bool QtxActionMenuMgr::ownAction ( QAction a,
MenuNode node 
) const
private

Check if action belongs to the menu manager.

Parameters
aaction being checked
nodeparent menu node
Returns
true if action belongs to the menu node

References QtxActionMenuMgr::MenuNode::children, itemAction(), and menuAction().

◆ prepend() [1/3]

int QtxActionMenuMgr::prepend ( const int  id,
const int  pId,
const int  group 
)

Create and add menu item action to the beginning of menu.

Parameters
idaction ID
pIdparent menu action ID
groupgroup ID
Returns
action ID

References insert().

◆ prepend() [2/3]

int QtxActionMenuMgr::prepend ( const QString &  title,
const int  pId,
const int  group,
const int  id = -1 
)

Create and add menu item action to the beginning of menu.

Parameters
titlemenu text
pIdparent menu action ID
groupgroup ID
idaction ID
Returns
action ID

References insert().

◆ prepend() [3/3]

int QtxActionMenuMgr::prepend ( QAction a,
const int  pId,
const int  group 
)

Create and add menu item action to the beginning of menu.

Parameters
aaction
pIdparent menu action ID
groupgroup ID
Returns
action ID

References insert().

◆ remove() [1/2]

void QtxActionMenuMgr::remove ( const int  id)

Remove menu item with given id.

Parameters
idmenu action ID

References removeMenu(), and QtxActionMgr::update().

◆ remove() [2/2]

void QtxActionMenuMgr::remove ( const int  id,
const int  pId,
const int  group = -1 
)

Remove menu item with given id.

Parameters
idmenu action ID
pIdparent menu action ID
groupgroup ID

References QtxActionMenuMgr::MenuNode::children, find(), QtxActionMenuMgr::MenuNode::id, itemAction(), menuAction(), menuWidget(), myMenus, myRoot, and QtxActionMgr::triggerUpdate().

◆ removeMenu()

void QtxActionMenuMgr::removeMenu ( const int  id,
MenuNode startNode 
)
protected

Removes menu node (with all its children).

Parameters
idmenu action ID
startNodeparent menu node which search starts from (if 0, search starts from root)

References QtxActionMenuMgr::MenuNode::children, and myRoot.

◆ setEmptyEnabled()

void QtxActionMenuMgr::setEmptyEnabled ( const int  id,
const bool  enable 
)

Enable/disable empty menu.

Parameters
idmenu item ID
enableif true, empty menu will be enabled, otherwise empty menu will be disabled

References QtxActionMenuMgr::MenuNode::emptyEnabled, find(), menuAction(), and updateMenu().

◆ setMenuWidget()

void QtxActionMenuMgr::setMenuWidget ( QWidget mw)
protected

Assign new menu widget to the menu manager.

Parameters
mwnew menu widget

References myMenu, onDestroyed(), and QtxActionMgr::triggerUpdate().

◆ setShown()

void QtxActionMenuMgr::setShown ( const int  id,
const bool  on 
)

Set visibility status for menu item with given id.

Parameters
idmenu action ID
onnew visibility status
See also
isShown()

References find(), QtxActionMenuMgr::MenuNode::id, myRoot, and QtxActionMgr::triggerUpdate().

◆ setVisible()

void QtxActionMenuMgr::setVisible ( const int  actId,
const int  place,
const bool  v 
)
virtual

Set action's visibility flag.

Parameters
actIdaction ID
placesome parent action ID
vnew visibility state
See also
isVisible()

Reimplemented from QtxActionMgr.

References find(), and QtxActionMenuMgr::MenuNode::visible.

◆ show()

void QtxActionMenuMgr::show ( const int  id)

Show menu item with given id.

Parameters
idmenu action ID
See also
hide()

References setShown().

◆ simplifySeparators()

void QtxActionMenuMgr::simplifySeparators ( QWidget wid)
private

Remove extra separators from menu widget.

Parameters
widmenu widget to be processed

References Qtx::simplifySeparators().

◆ triggerUpdate()

void QtxActionMenuMgr::triggerUpdate ( const int  id,
const bool  rec = true 
)
private

Perform delayed menu update.

Parameters
idmenu item ID
recif true, perform recursive update

References myUpdateIds, and QtxActionMgr::triggerUpdate().

◆ updateContent()

void QtxActionMenuMgr::updateContent ( )
protectedvirtual

Called when delayed content update is performed.

Customizes the content update operation.

Reimplemented from QtxActionMgr.

References find(), myRoot, myUpdateIds, and updateMenu().

◆ updateMenu()

void QtxActionMenuMgr::updateMenu ( MenuNode startNode = 0,
const bool  rec = true,
const bool  updParent = true 
)
protected

Update menu.

Does nothing if update is disabled.

Parameters
startNodestart menu item to be updated
recif true, perform recursive update
updParentif true update also parent item (without recursion)
See also
isUpdatesEnabled() and setUpdatesEnabled()

References QtxActionMenuMgr::MenuNode::children, QtxActionMenuMgr::MenuNode::emptyEnabled, QtxActionMenuMgr::MenuNode::id, QtxActionMgr::isUpdatesEnabled(), isVisible(), itemAction(), menuAction(), menuWidget(), myRoot, ownAction(), QtxActionMenuMgr::MenuNode::parent, and simplifySeparators().

Member Data Documentation

◆ myMenu

QWidget* QtxActionMenuMgr::myMenu
private

menu widget

◆ myMenus

MenuMap QtxActionMenuMgr::myMenus
private

actions map

◆ myRoot

MenuNode* QtxActionMenuMgr::myRoot
private

root menu node

◆ myUpdateIds

QMap<int, bool> QtxActionMenuMgr::myUpdateIds
private

list of actions ID being updated


The documentation for this class was generated from the following files: