Version: 9.12.0
QtxActionToolMgr Class Reference

Toolbar actions manager. More...

#include <QtxActionToolMgr.h>

Inheritance diagram for QtxActionToolMgr:
Inheritance graph

Classes

struct  ToolBarInfo
 
class  ToolCreator
 Toolbars creator. More...
 
class  ToolNode
 Represents a toolbutton inside toolbar structure. More...
 

Public Member Functions

 QtxActionToolMgr (QMainWindow *)
 Constructor. More...
 
virtual ~QtxActionToolMgr ()
 Destructor. More...
 
QMainWindowmainWindow () const
 Get parent main window. More...
 
int createToolBar (const QString &, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it. More...
 
int createToolBar (const QString &, const QString &, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it. More...
 
int createToolBar (const QString &, bool, Qt::ToolBarAreas=Qt::AllToolBarAreas, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it. More...
 
int createToolBar (const QString &, const QString &, bool, Qt::ToolBarAreas=Qt::AllToolBarAreas, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it. More...
 
void removeToolBar (const QString &)
 Remove toolbar. More...
 
void removeToolBar (const int)
 Remove toolbar. More...
 
int insert (const int, const int, const int=-1)
 Insert action into toolbar. More...
 
int insert (QAction *, const int, const int=-1)
 Insert action into toolbar. More...
 
int insert (const int, const QString &, const int=-1)
 Insert action into toolbar. More...
 
int insert (QAction *, const QString &, const int=-1)
 Insert action into toolbar. More...
 
int append (const int, const int)
 Append action to the end of toolbar. More...
 
int append (QAction *, const int)
 Append action to the end of toolbar. More...
 
int append (const int, const QString &)
 Append action to the end of toolbar. More...
 
int append (QAction *, const QString &)
 Append action to the end of toolbar. More...
 
int prepend (const int, const int)
 Insert action to the beginning of toolbar. More...
 
int prepend (QAction *, const int)
 Insert action to the beginning of toolbar. More...
 
int prepend (const int, const QString &)
 Insert action to the beginning of toolbar. More...
 
int prepend (QAction *, const QString &)
 Insert action to the beginning of toolbar. More...
 
virtual bool isVisible (const int, const int) const
 Check if an action with given id is visible in the toolbar tid. More...
 
virtual void setVisible (const int, const int, const bool)
 Show/hide action with given id in the toolbar tid. More...
 
void show (const int)
 Show action (in all toolbars). More...
 
void hide (const int)
 Hide action (in all toolbars). More...
 
bool isShown (const int) const
 Get visibility status for toolbar action with given id. More...
 
void setShown (const int, const bool)
 Set visibility status for toolbar action with given id. More...
 
void remove (const int, const int)
 Remove action from toolbar. More...
 
void remove (const int, const QString &)
 Remove action from toolbar. More...
 
void clear (const int)
 Remove all actions from toolbar. More...
 
void clear (const QString &)
 Remove all actions from toolbar. More...
 
QToolBartoolBar (const int) const
 Get toolbar by given tid. More...
 
QToolBartoolBar (const QString &) const
 Get toolbar by given title. More...
 
QIntList toolBarsIds () const
 
bool hasToolBar (const int) const
 Check if toolbar with given id already registered. More...
 
bool hasToolBar (const QString &) const
 Check if toolbar with given id already registered. More...
 
bool containsAction (const int, const int=-1) const
 Check if toolbar contains given action. More...
 
int index (const int, const int) const
 Get index of the action id within the toolbar tid. More...
 
virtual bool load (const QString &, QtxActionMgr::Reader &)
 Load toolbar contents from the file. More...
 
int find (QToolBar *) const
 Get toolbar identifier. 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 Slots

void onToolBarDestroyed ()
 Called when toolbar is destroyed. More...
 

Protected Member Functions

int find (const QString &) const
 Search toolbar by given name. More...
 
QToolBarfind (const QString &, QMainWindow *) const
 Search toolbar with given title owned by main window \mw. More...
 
virtual void internalUpdate ()
 Update all registered toolbars. More...
 
void updateToolBar (const int)
 Update toolbar. More...
 
virtual void updateContent ()
 Called when delayed content update is performed. More...
 
- Protected Member Functions inherited from QtxActionMgr
int generateId () const
 Generate unique action identifier. More...
 
void triggerUpdate ()
 Perform delayed update. More...
 
virtual void actionChanged (int)
 Internal action changing response operation. More...
 

Private Types

typedef QList< ToolNodeNodeList
 toolbar nodes list More...
 
typedef QMap< int, ToolBarInfoToolBarMap
 toolbars map More...
 

Private Member Functions

void simplifySeparators (QToolBar *)
 Remove extra separators from the toolbar. More...
 
void triggerUpdate (const int)
 Perform delayed toolbar update. More...
 

Private Attributes

ToolBarMap myToolBars
 toobars map More...
 
QMainWindowmyMainWindow
 parent main window More...
 
QMap< int, int > 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

Toolbar actions manager.

Toolbar manager allows using of set of action for automatic generating of application toolbars and dynamic update of toolbars contents.

Use insert(), append() and remove() methods to create toolbar and add actions to it. Methods show(), hide() allow displaying/erasing of specified toolbar items.

Toolbar manager automatically optimizes toolbars by removing extra separators, etc.

Member Typedef Documentation

◆ NodeList

toolbar nodes list

◆ ToolBarMap

typedef QMap<int, ToolBarInfo> QtxActionToolMgr::ToolBarMap
private

toolbars map

Constructor & Destructor Documentation

◆ QtxActionToolMgr()

QtxActionToolMgr::QtxActionToolMgr ( QMainWindow p)

Constructor.

Parameters
pparent main window

◆ ~QtxActionToolMgr()

QtxActionToolMgr::~QtxActionToolMgr ( )
virtual

Destructor.

Member Function Documentation

◆ append() [1/4]

int QtxActionToolMgr::append ( const int  id,
const int  tid 
)

Append action to the end of toolbar.

Parameters
idaction ID
tidtoolbar ID
Returns
action ID

References insert().

◆ append() [2/4]

int QtxActionToolMgr::append ( const int  id,
const QString &  title 
)

Append action to the end of toolbar.

Parameters
idaction ID
titletoolbar title
Returns
action ID

References insert().

◆ append() [3/4]

int QtxActionToolMgr::append ( QAction a,
const int  tid 
)

Append action to the end of toolbar.

Parameters
aaction
tidtoolbar ID
Returns
action ID

References insert().

◆ append() [4/4]

int QtxActionToolMgr::append ( QAction a,
const QString &  title 
)

Append action to the end of toolbar.

Parameters
aaction
titletoolbar title
Returns
action ID

References insert().

◆ clear() [1/2]

void QtxActionToolMgr::clear ( const int  tid)

Remove all actions from toolbar.

Parameters
tidtoolbar ID

References myToolBars, and QtxActionMgr::triggerUpdate().

◆ clear() [2/2]

void QtxActionToolMgr::clear ( const QString &  title)

Remove all actions from toolbar.

Parameters
titletoolbar title

References clear(), and find().

◆ containsAction()

bool QtxActionToolMgr::containsAction ( const int  id,
const int  tid = -1 
) const

Check if toolbar contains given action.

Parameters
idaction ID
tidtoolbar ID
Returns
true if toolbar contains action

References myToolBars.

◆ createToolBar() [1/4]

int QtxActionToolMgr::createToolBar ( const QString &  title,
bool  floatable,
Qt::ToolBarAreas  dockAreas = Qt::AllToolBarAreas,
int  tid = -1,
QMainWindow mw = 0,
bool  vis = true 
)

Create toolbar and assign id to it.

If tid is less than 0, the identifier is generated automatically. If toolbar with given tid is already registered, the toolbar will not be created.

Parameters
titletoolbar title
floatableif true, new toolbar is made floatable
dockAreasdock areas of the main window where the new toolbar can be situated
tidrequested toolbar ID
mwparent main window; if it is null, the tool manager's main window is used
visshow toolbar visible immediately after creation (true by default)
Returns
id of created/found toolbar

References createToolBar().

◆ createToolBar() [2/4]

int QtxActionToolMgr::createToolBar ( const QString &  title,
const QString &  name,
bool  floatable,
Qt::ToolBarAreas  dockAreas = Qt::AllToolBarAreas,
int  tid = -1,
QMainWindow mw = 0,
bool  vis = true 
)

Create toolbar and assign id to it.

If tid is less than 0, the identifier is generated automatically. If toolbar with given tid is already registered, the toolbar will not be created.

The parameter name can be specified to give an unique string identifier to the toolbar. This can be useful in the multi-language environment where identifier of the toolbar should not be dependant on the language chosen (e.g. to store positions of toolbars of main menu in the preferences).

Parameters
titletoolbar title
nametoolbar name (identifier)
floatableif true, new toolbar is made floatable
dockAreasdock areas of the main window where the new toolbar can be situated
tidrequested toolbar ID
mwparent main window; if it is null, the tool manager's main window is used
visshow toolbar visible immediately after creation (true by default)
Returns
id of created/found toolbar

References find(), mainWindow(), myToolBars, onToolBarDestroyed(), and QtxActionToolMgr::ToolBarInfo::toolBar.

◆ createToolBar() [3/4]

int QtxActionToolMgr::createToolBar ( const QString &  title,
const QString &  name,
int  tid = -1,
QMainWindow mw = 0,
bool  vis = true 
)

Create toolbar and assign id to it.

If tid is less than 0, the identifier is generated automatically. If toolbar with given tid is already registered, the toolbar will not be created.

The parameter name can be specified to give an unique string identifier to the toolbar. This can be useful in the multi-language environment where identifier of the toolbar should not be dependant on the language chosen (e.g. to store positions of toolbars of main menu in the preferences).

Parameters
titletoolbar title
nametoolbar name (identifier)
tidrequested toolbar ID
mwparent main window; if it is null, the tool manager's main window is used
visshow toolbar visible immediately after creation (true by default)
Returns
id of created/found toolbar

References createToolBar().

◆ createToolBar() [4/4]

int QtxActionToolMgr::createToolBar ( const QString &  title,
int  tid = -1,
QMainWindow mw = 0,
bool  vis = true 
)

Create toolbar and assign id to it.

If tid is less than 0, the identifier is generated automatically. If toolbar with given tid is already registered, the toolbar will not be created.

Parameters
titletoolbar title
tidrequested toolbar ID
mwparent main window; if it is null, the tool manager's main window is used
visshow toolbar visible immediately after creation (true by default)
Returns
id of created/found toolbar

◆ find() [1/3]

int QtxActionToolMgr::find ( const QString &  title) const
protected

Search toolbar by given name.

Parameters
titletoolbar title
Returns
toolbar ID or -1 if it is not found

References myToolBars.

◆ find() [2/3]

QToolBar * QtxActionToolMgr::find ( const QString &  title,
QMainWindow mw 
) const
protected

Search toolbar with given title owned by main window \mw.

Parameters
titletoolbar title
mwmain window
Returns
toolbar or 0 if it is not found

◆ find() [3/3]

int QtxActionToolMgr::find ( QToolBar tb) const

Get toolbar identifier.

Parameters
tbtoolbar
Returns
toolbar ID or -1 if toolbar is not registered

References myToolBars.

◆ hasToolBar() [1/2]

bool QtxActionToolMgr::hasToolBar ( const int  tid) const

Check if toolbar with given id already registered.

Parameters
tidtoolbar ID
Returns
true if toolbar is registered in the toolbar manager

References myToolBars.

◆ hasToolBar() [2/2]

bool QtxActionToolMgr::hasToolBar ( const QString &  title) const

Check if toolbar with given id already registered.

Parameters
titletoolbar title
Returns
true if toolbar is registered in the toolbar manager

References find().

◆ hide()

void QtxActionToolMgr::hide ( const int  id)

Hide action (in all toolbars).

Parameters
idaction ID

References setShown().

◆ index()

int QtxActionToolMgr::index ( const int  id,
const int  tid 
) const

Get index of the action id within the toolbar tid.

Parameters
idaction ID
tidtoolbar ID
Returns
index of the action in the toolbar or -1 if action is not contained in the toolbar

References myToolBars.

◆ insert() [1/4]

int QtxActionToolMgr::insert ( const int  id,
const int  tid,
const int  idx = -1 
)

Insert action into toolbar.

Parameters
idaction ID
tidtoolbar ID
idxaction index in the toolbar (if < 0, action is appended to the end)
Returns
action ID

References QtxActionMgr::contains(), hasToolBar(), index(), myToolBars, and QtxActionMgr::triggerUpdate().

◆ insert() [2/4]

int QtxActionToolMgr::insert ( const int  id,
const QString &  title,
const int  idx = -1 
)

Insert action into toolbar.

Parameters
idaction ID
titletoolbar title
idxaction index in the toolbar (if < 0, action is appended to the end)
Returns
action ID

References createToolBar(), and insert().

◆ insert() [3/4]

int QtxActionToolMgr::insert ( QAction a,
const int  tid,
const int  idx = -1 
)

Insert action into toolbar.

Parameters
aaction
tidtoolbar ID
idxaction index in the toolbar (if < 0, action is appended to the end)
Returns
action ID

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

◆ insert() [4/4]

int QtxActionToolMgr::insert ( QAction a,
const QString &  title,
const int  idx = -1 
)

Insert action into toolbar.

Parameters
aaction
titletoolbar title
idxaction index in the toolbar (if < 0, action is appended to the end)
Returns
action ID

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

◆ internalUpdate()

void QtxActionToolMgr::internalUpdate ( )
protectedvirtual

Update all registered toolbars.

Reimplemented from QtxActionMgr.

References QtxActionMgr::isUpdatesEnabled(), myToolBars, myUpdateIds, and updateToolBar().

◆ isShown()

bool QtxActionToolMgr::isShown ( const int  id) const

Get visibility status for toolbar action with given id.

Parameters
idaction ID
Returns
true if action is shown in all toolbars

References QtxActionToolMgr::ToolNode::id, and myToolBars.

◆ isVisible()

bool QtxActionToolMgr::isVisible ( const int  id,
const int  tid 
) const
virtual

Check if an action with given id is visible in the toolbar tid.

Parameters
idaction ID
tidtoolbar ID
Returns
true if action is shown in the toolbar

Reimplemented from QtxActionMgr.

References QtxActionToolMgr::ToolNode::id, myToolBars, QtxActionToolMgr::ToolBarInfo::nodes, and QtxActionToolMgr::ToolNode::visible.

◆ load()

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

Load toolbar contents from the file.

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

References QtxActionMgr::Reader::read().

◆ mainWindow()

QMainWindow * QtxActionToolMgr::mainWindow ( ) const

Get parent main window.

Returns
main window pointer

References myMainWindow.

◆ onToolBarDestroyed

void QtxActionToolMgr::onToolBarDestroyed ( )
protectedslot

Called when toolbar is destroyed.

Clears internal pointer to the toolbar to disable crashes.

References find(), and myToolBars.

◆ prepend() [1/4]

int QtxActionToolMgr::prepend ( const int  id,
const int  tid 
)

Insert action to the beginning of toolbar.

Parameters
idaction ID
tidtoolbar ID
Returns
action ID

References insert().

◆ prepend() [2/4]

int QtxActionToolMgr::prepend ( const int  id,
const QString &  title 
)

Insert action to the beginning of toolbar.

Parameters
idaction ID
titletoolbar title
Returns
action ID

References insert().

◆ prepend() [3/4]

int QtxActionToolMgr::prepend ( QAction a,
const int  tid 
)

Insert action to the beginning of toolbar.

Parameters
aaction
tidtoolbar ID
Returns
action ID

References insert().

◆ prepend() [4/4]

int QtxActionToolMgr::prepend ( QAction a,
const QString &  title 
)

Insert action to the beginning of toolbar.

Parameters
aaction ID
titletoolbar title
Returns
action ID

References insert().

◆ remove() [1/2]

void QtxActionToolMgr::remove ( const int  id,
const int  tid 
)

Remove action from toolbar.

Parameters
idaction ID
tidtoolbar ID

References myToolBars, and QtxActionMgr::triggerUpdate().

◆ remove() [2/2]

void QtxActionToolMgr::remove ( const int  id,
const QString &  title 
)

Remove action from toolbar.

Parameters
idaction ID
titletoolbar title

References find(), and remove().

◆ removeToolBar() [1/2]

void QtxActionToolMgr::removeToolBar ( const int  tid)

Remove toolbar.

Parameters
tidtoolbar ID

References myToolBars.

◆ removeToolBar() [2/2]

void QtxActionToolMgr::removeToolBar ( const QString &  title)

Remove toolbar.

Parameters
titletoolbar title

References find().

◆ setShown()

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

Set visibility status for toolbar action with given id.

Parameters
idaction ID
onnew visibility status

References myToolBars, and setVisible().

◆ setVisible()

void QtxActionToolMgr::setVisible ( const int  id,
const int  tid,
const bool  on 
)
virtual

Show/hide action with given id in the toolbar tid.

Parameters
idaction ID
tidtoolbar ID
onnew visibility status

Reimplemented from QtxActionMgr.

References QtxActionToolMgr::ToolNode::id, myToolBars, QtxActionMgr::triggerUpdate(), updateContent(), and QtxActionToolMgr::ToolNode::visible.

◆ show()

void QtxActionToolMgr::show ( const int  id)

Show action (in all toolbars).

Parameters
idaction ID

References setShown().

◆ simplifySeparators()

void QtxActionToolMgr::simplifySeparators ( QToolBar tb)
private

Remove extra separators from the toolbar.

Parameters
tbtoolbar

References Qtx::simplifySeparators().

◆ toolBar() [1/2]

QToolBar * QtxActionToolMgr::toolBar ( const int  tid) const

Get toolbar by given tid.

Parameters
tidtoolbar ID
Returns
toolbar or 0 if it is not found

References myToolBars.

◆ toolBar() [2/2]

QToolBar * QtxActionToolMgr::toolBar ( const QString &  title) const

Get toolbar by given title.

Parameters
titletoolbar title
Returns
toolbar or 0 if it is not found

References find(), and toolBar().

◆ toolBarsIds()

QIntList QtxActionToolMgr::toolBarsIds ( ) const

\bried Get all registered toolbars identifiers

Returns
list of toolbars ids

References myToolBars.

◆ triggerUpdate()

void QtxActionToolMgr::triggerUpdate ( const int  tid)
private

Perform delayed toolbar update.

Parameters
tidtoolbar ID

References myUpdateIds, and QtxActionMgr::triggerUpdate().

◆ updateContent()

void QtxActionToolMgr::updateContent ( )
protectedvirtual

Called when delayed content update is performed.

Customizes the content update operation.

Reimplemented from QtxActionMgr.

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

◆ updateToolBar()

void QtxActionToolMgr::updateToolBar ( const int  tid)
protected

Update toolbar.

Parameters
tidtoolbar ID

References QtxActionMgr::action(), QtxActionMgr::isUpdatesEnabled(), isVisible(), myToolBars, and simplifySeparators().

Member Data Documentation

◆ myMainWindow

QMainWindow* QtxActionToolMgr::myMainWindow
private

parent main window

◆ myToolBars

ToolBarMap QtxActionToolMgr::myToolBars
private

toobars map

◆ myUpdateIds

QMap<int,int> QtxActionToolMgr::myUpdateIds
private

list of actions ID being updated


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