Version: 6.3.1
Data Structures | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

QtxActionToolMgr Class Reference

Toolbar actions manager. More...

#include <QtxActionToolMgr.h>

Inheritance diagram for QtxActionToolMgr:
Inheritance graph

Data Structures

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

Public Member Functions

 QtxActionToolMgr (QMainWindow *)
 Constructor.
virtual ~QtxActionToolMgr ()
 Destructor.
QMainWindowmainWindow () const
 Get parent main window.
int createToolBar (const QString &, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it.
int createToolBar (const QString &, bool, Qt::ToolBarAreas=Qt::AllToolBarAreas, int=-1, QMainWindow *=0, bool=true)
 Create toolbar and assign id to it.
void removeToolBar (const QString &)
 Remove toolbar.
void removeToolBar (const int)
 Remove toolbar.
int insert (const int, const int, const int=-1)
 Insert action into toolbar.
int insert (QAction *, const int, const int=-1)
 Insert action into toolbar.
int insert (const int, const QString &, const int=-1)
 Insert action into toolbar.
int insert (QAction *, const QString &, const int=-1)
 Insert action into toolbar.
int append (const int, const int)
 Append action to the end of toolbar.
int append (QAction *, const int)
 Append action to the end of toolbar.
int append (const int, const QString &)
 Append action to the end of toolbar.
int append (QAction *, const QString &)
 Append action to the end of toolbar.
int prepend (const int, const int)
 Insert action to the beginning of toolbar.
int prepend (QAction *, const int)
 Insert action to the beginning of toolbar.
int prepend (const int, const QString &)
 Insert action to the beginning of toolbar.
int prepend (QAction *, const QString &)
 Insert action to the beginning of toolbar.
virtual bool isVisible (const int, const int) const
 Check if an action with given id is visible in the toolbar tid.
virtual void setVisible (const int, const int, const bool)
 Show/hide action with given id in the toolbar tid.
void show (const int)
 Show action (in all toolbars).
void hide (const int)
 Hide action (in all toolbars).
bool isShown (const int) const
 Get visibility status for toolbar action with given id.
void setShown (const int, const bool)
 Set visibility status for toolbar action with given id.
void remove (const int, const int)
 Remove action from toolbar.
void remove (const int, const QString &)
 Remove action from toolbar.
QToolBartoolBar (const int) const
 Get toolbar by given tid.
QToolBartoolBar (const QString &) const
 Get toolbar by given title.
QIntList toolBarsIds () const
bool hasToolBar (const int) const
 Check if toolbar with given id already registered.
bool hasToolBar (const QString &) const
 Check if toolbar with given id already registered.
bool containsAction (const int, const int=-1) const
 Check if toolbar contains given action.
int index (const int, const int) const
 Get index of the action id within the toolbar tid.
virtual bool load (const QString &, QtxActionMgr::Reader &)
 Load toolbar contents from the file.
int find (QToolBar *) const
 Get toolbar identifier.
virtual int registerAction (QAction *, const int=-1)
 Register an action in the internal map.
virtual void unRegisterAction (const int)
 Unregister action from internal map.
QActionaction (const int) const
 Get action by specified identifier.
int actionId (const QAction *) const
 Get action identifier.
bool contains (const int) const
 Check if an action with given id is registered in the action manager.
int count () const
 Get total number of registered actions.
bool isEmpty () const
 Check if there are no actions registered in the action manager.
QIntList idList () const
 Get all registered actions identifiers.
bool isUpdatesEnabled () const
 Check if update is enabled.
virtual void setUpdatesEnabled (const bool)
 Enable/disable update operation.
void update ()
 Update actions.
virtual bool isEnabled (const int) const
 Check is action with given id is enabled.
virtual void setEnabled (const int, const bool)

Static Public Member Functions

static QActionseparator (const bool=false)
 Create new separator action.

Protected Slots

void onToolBarDestroyed ()
 Called when toolbar is destroyed.

Protected Member Functions

int find (const QString &) const
 Search toolbar by given name.
QToolBarfind (const QString &, QMainWindow *) const
 Search toolbar with given title owned by main window .
virtual void internalUpdate ()
 Update all registered toolbars.
void updateToolBar (const int)
 Update toolbar.
virtual void updateContent ()
 Called when delayed content update is performed.
int generateId () const
 Generate unique action identifier.
void triggerUpdate ()
 Perform delayed update.

Private Types

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

Private Member Functions

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

Private Attributes

ToolBarMap myToolBars
 toobars map
QMainWindowmyMainWindow
 parent main window
QMap< int, int > myUpdateIds
 list of actions ID being updated

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

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

References myMainWindow.

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,
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 find(), mainWindow(), myToolBars, onToolBarDestroyed(), and QtxActionToolMgr.ToolBarInfo.toolBar.

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

References find().

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

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

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

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

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.

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(), and QtxActionToolMgr.ToolNode.visible.

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

References setShown().

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

References setShown().

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.

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

References myToolBars, and setVisible().

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

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.

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

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

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

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

References myToolBars.

void QtxActionToolMgr::onToolBarDestroyed ( ) [protected, slot]

Clears internal pointer to the toolbar to disable crashes.

References find(), and 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
void QtxActionToolMgr::internalUpdate ( ) [protected, virtual]
void QtxActionToolMgr::updateToolBar ( const int  tid) [protected]
void QtxActionToolMgr::updateContent ( ) [protected, virtual]

Customizes the content update operation.

Reimplemented from QtxActionMgr.

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

void QtxActionToolMgr::simplifySeparators ( QToolBar tb) [private]
Parameters:
tbtoolbar
void QtxActionToolMgr::triggerUpdate ( const int  tid) [private]
Parameters:
tidtoolbar ID

References myUpdateIds, and QtxActionMgr.triggerUpdate().

int QtxActionMgr::registerAction ( QAction a,
const int  userId = -1 
) [virtual, inherited]

If userId is less than 0, the identifier for the action is generated automatically. If action with given userId is already registered, it will be re-registered.

Parameters:
aaction to be registered
userIdaction ID
Returns:
action ID (the same as userId or generated one)
See also:
unRegisterAction()

References QtxActionMgr.actionId(), QtxActionMgr.contains(), QtxActionMgr.generateId(), QtxActionMgr.myActions, and QtxActionMgr.unRegisterAction().

void QtxActionMgr::unRegisterAction ( const int  id) [virtual, inherited]
Parameters:
idaction ID
See also:
registerAction()

Reimplemented in QtxPopupMgr.

References QtxActionMgr.contains(), and QtxActionMgr.myActions.

QAction * QtxActionMgr::action ( const int  id) const [inherited]
Parameters:
idaction ID
Returns:
action (or 0 if id is invalid)
See also:
actionId()

References QtxActionMgr.contains(), and QtxActionMgr.myActions.

int QtxActionMgr::actionId ( const QAction a) const [inherited]
Parameters:
aaction
Returns:
action ID (or -1 if action is not found)
See also:
action()

References test_table.a, and QtxActionMgr.myActions.

bool QtxActionMgr::contains ( const int  id) const [inherited]
Parameters:
idaction ID
Returns:
true if internal map contains action with such identifier

References QtxActionMgr.myActions.

int QtxActionMgr::count ( ) const [inherited]
Returns:
number of actions in the internal map
See also:
isEmpty()

References QtxActionMgr.myActions.

bool QtxActionMgr::isEmpty ( ) const [inherited]
Returns:
true if internal map is empty
See also:
count()

References QtxActionMgr.myActions.

QIntList QtxActionMgr::idList ( ) const [inherited]
Returns:
list of actions identifiers

References QtxActionMgr.myActions.

bool QtxActionMgr::isUpdatesEnabled ( ) const [inherited]
Returns:
true if update is enabled
See also:
setUpdatesEnabled(), update()

References QtxActionMgr.myUpdate.

void QtxActionMgr::setUpdatesEnabled ( const bool  upd) [virtual, inherited]
Parameters:
updnew state
See also:
isUpdatesEnabled(), update()

References QtxActionMgr.myUpdate.

void QtxActionMgr::update ( ) [inherited]

Calls virtual function internalUpdate to update the contents. Does nothing if update is disabled.

See also:
setUpdatesEnabled(), isUpdatesEnabled(), internalUpdate()

References QtxActionMgr.internalUpdate(), QtxActionMgr.isUpdatesEnabled(), and QtxActionMgr.myUpdTimer.

bool QtxActionMgr::isEnabled ( const int  id) const [virtual, inherited]
Parameters:
idaction ID
Returns:
true if action is enabled

References test_table.a, and QtxActionMgr.action().

void QtxActionMgr::setEnabled ( const int  id,
const bool  enable 
) [virtual, inherited]

Enable/disable action with given id.

Parameters:
idaction ID
enablenew state

References test_table.a, and QtxActionMgr.action().

QAction * QtxActionMgr::separator ( const bool  own = false) [static, inherited]

If own is true, then the caller is responsible for the action destroying. If own is false, new separator action will be owned by the action manager which will destroy it on application exit.

Parameters:
ownownership flag
Returns:
new separator action

References test_table.a, and qtxSeparatorActionCleanup().

int QtxActionMgr::generateId ( ) const [protected, inherited]
Returns:
new ID
void QtxActionMgr::triggerUpdate ( ) [protected, inherited]

Field Documentation

QMap<int,int> QtxActionToolMgr.myUpdateIds [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS