Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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...
 
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 . 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...
 

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 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

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

Constructor & Destructor Documentation

QtxActionToolMgr::QtxActionToolMgr ( QMainWindow p)
Parameters
pparent main window
QtxActionToolMgr::~QtxActionToolMgr ( )
virtual

Member Function Documentation

int QtxActionToolMgr::append ( const int  id,
const int  tid 
)
Parameters
idaction ID
tidtoolbar ID
Returns
action ID

References insert().

int QtxActionToolMgr::append ( QAction a,
const int  tid 
)
Parameters
aaction
tidtoolbar ID
Returns
action ID

References insert().

int QtxActionToolMgr::append ( const int  id,
const QString &  title 
)
Parameters
idaction ID
titletoolbar title
Returns
action ID

References insert().

int QtxActionToolMgr::append ( QAction a,
const QString &  title 
)
Parameters
aaction
titletoolbar title
Returns
action ID

References insert().

bool QtxActionToolMgr::containsAction ( const int  id,
const int  tid = -1 
) const
Parameters
idaction ID
tidtoolbar ID
Returns
true if toolbar contains action

References myToolBars.

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

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
int QtxActionToolMgr::createToolBar ( const QString &  title,
const QString &  name,
int  tid = -1,
QMainWindow mw = 0,
bool  vis = true 
)

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().

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

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().

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 
)

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.

int QtxActionToolMgr::find ( QToolBar tb) const
Parameters
tbtoolbar
Returns
toolbar ID or -1 if toolbar is not registered

References myToolBars.

int QtxActionToolMgr::find ( const QString &  title) const
protected
Parameters
titletoolbar title
Returns
toolbar ID or -1 if it is not found

References myToolBars.

QToolBar * QtxActionToolMgr::find ( const QString &  title,
QMainWindow mw 
) const
protected
Parameters
titletoolbar title
mwmain window
Returns
toolbar or 0 if it is not found
bool QtxActionToolMgr::hasToolBar ( const int  tid) const
Parameters
tidtoolbar ID
Returns
true if toolbar is registered in the toolbar manager

References myToolBars.

bool QtxActionToolMgr::hasToolBar ( const QString &  title) const
Parameters
titletoolbar title
Returns
true if toolbar is registered in the toolbar manager

References find().

void QtxActionToolMgr::hide ( const int  id)
Parameters
idaction ID

References setShown().

int QtxActionToolMgr::index ( const int  id,
const int  tid 
) const
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.

int QtxActionToolMgr::insert ( const int  id,
const int  tid,
const int  idx = -1 
)
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().

int QtxActionToolMgr::insert ( QAction a,
const int  tid,
const int  idx = -1 
)
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().

int QtxActionToolMgr::insert ( const int  id,
const QString &  title,
const int  idx = -1 
)
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().

int QtxActionToolMgr::insert ( QAction a,
const QString &  title,
const int  idx = -1 
)
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().

void QtxActionToolMgr::internalUpdate ( )
protectedvirtual
bool QtxActionToolMgr::isShown ( const int  id) const
Parameters
idaction ID
Returns
true if action is shown in all toolbars

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

bool QtxActionToolMgr::isVisible ( const int  id,
const int  tid 
) const
virtual
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.

bool QtxActionToolMgr::load ( const QString &  fname,
QtxActionMgr::Reader r 
)
virtual
Parameters
fnamefile name
ractions reader
Returns
true on success and false on error

References QtxActionMgr::Reader::read().

QMainWindow * QtxActionToolMgr::mainWindow ( ) const
Returns
main window pointer

References myMainWindow.

void QtxActionToolMgr::onToolBarDestroyed ( )
protectedslot

Clears internal pointer to the toolbar to disable crashes.

References find(), and myToolBars.

int QtxActionToolMgr::prepend ( const int  id,
const int  tid 
)
Parameters
idaction ID
tidtoolbar ID
Returns
action ID

References insert().

int QtxActionToolMgr::prepend ( QAction a,
const int  tid 
)
Parameters
aaction
tidtoolbar ID
Returns
action ID

References insert().

int QtxActionToolMgr::prepend ( const int  id,
const QString &  title 
)
Parameters
idaction ID
titletoolbar title
Returns
action ID

References insert().

int QtxActionToolMgr::prepend ( QAction a,
const QString &  title 
)
Parameters
aaction ID
titletoolbar title
Returns
action ID

References insert().

void QtxActionToolMgr::remove ( const int  id,
const int  tid 
)
Parameters
idaction ID
tidtoolbar ID

References myToolBars, and QtxActionMgr::triggerUpdate().

void QtxActionToolMgr::remove ( const int  id,
const QString &  title 
)
Parameters
idaction ID
titletoolbar title

References find().

void QtxActionToolMgr::removeToolBar ( const QString &  title)
Parameters
titletoolbar title

References find().

void QtxActionToolMgr::removeToolBar ( const int  tid)
Parameters
tidtoolbar ID

References myToolBars.

void QtxActionToolMgr::setShown ( const int  id,
const bool  on 
)
Parameters
idaction ID
onnew visibility status

References myToolBars, and setVisible().

void QtxActionToolMgr::setVisible ( const int  id,
const int  tid,
const bool  on 
)
virtual
Parameters
idaction ID
tidtoolbar ID
onnew visibility status

Reimplemented from QtxActionMgr.

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

void QtxActionToolMgr::show ( const int  id)
Parameters
idaction ID

References setShown().

void QtxActionToolMgr::simplifySeparators ( QToolBar tb)
private
Parameters
tbtoolbar

References Qtx::simplifySeparators().

QToolBar * QtxActionToolMgr::toolBar ( const int  tid) const
Parameters
tidtoolbar ID
Returns
toolbar or 0 if it is not found

References myToolBars.

QToolBar * QtxActionToolMgr::toolBar ( const QString &  title) const
Parameters
titletoolbar title
Returns
toolbar or 0 if it is not found

References find(), and toolBar().

QIntList QtxActionToolMgr::toolBarsIds ( ) const

Get all registered toolbars identifiers

Returns
list of toolbars ids

References myToolBars.

void QtxActionToolMgr::triggerUpdate ( const int  tid)
private
Parameters
tidtoolbar ID

References myUpdateIds, and QtxActionMgr::triggerUpdate().

void QtxActionToolMgr::updateContent ( )
protectedvirtual

Customizes the content update operation.

Reimplemented from QtxActionMgr.

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

void QtxActionToolMgr::updateToolBar ( const int  tid)
protected

Member Data Documentation

QMainWindow* QtxActionToolMgr::myMainWindow
private
ToolBarMap QtxActionToolMgr::myToolBars
private
QMap<int,int> QtxActionToolMgr::myUpdateIds
private

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