Toolbar actions manager. More...
#include <QtxActionToolMgr.h>
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... | |
QMainWindow * | mainWindow () 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... | |
QToolBar * | toolBar (const int) const |
Get toolbar by given tid. More... | |
QToolBar * | toolBar (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... | |
QAction * | action (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... | |
QToolBar * | find (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< ToolNode > | NodeList |
toolbar nodes list More... | |
typedef QMap< int, ToolBarInfo > | ToolBarMap |
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... | |
QMainWindow * | myMainWindow |
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 QAction * | separator (const bool=false) |
Create new separator action. More... | |
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.
|
private |
toolbar nodes list
|
private |
toolbars map
QtxActionToolMgr::QtxActionToolMgr | ( | QMainWindow * | p | ) |
Constructor.
p | parent main window |
|
virtual |
Destructor.
int QtxActionToolMgr::append | ( | const int | id, |
const int | tid | ||
) |
Append action to the end of toolbar.
id | action ID |
tid | toolbar ID |
References insert().
int QtxActionToolMgr::append | ( | const int | id, |
const QString & | title | ||
) |
Append action to the end of toolbar.
id | action ID |
title | toolbar title |
References insert().
int QtxActionToolMgr::append | ( | QAction * | a, |
const int | tid | ||
) |
Append action to the end of toolbar.
a | action |
tid | toolbar ID |
References insert().
int QtxActionToolMgr::append | ( | QAction * | a, |
const QString & | title | ||
) |
Append action to the end of toolbar.
a | action |
title | toolbar title |
References insert().
void QtxActionToolMgr::clear | ( | const int | tid | ) |
Remove all actions from toolbar.
tid | toolbar ID |
References myToolBars, and QtxActionMgr::triggerUpdate().
void QtxActionToolMgr::clear | ( | const QString & | title | ) |
bool QtxActionToolMgr::containsAction | ( | const int | id, |
const int | tid = -1 |
||
) | const |
Check if toolbar contains given action.
id | action ID |
tid | toolbar ID |
true
if toolbar contains action References myToolBars.
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.
title | toolbar title |
floatable | if true , new toolbar is made floatable |
dockAreas | dock areas of the main window where the new toolbar can be situated |
tid | requested toolbar ID |
mw | parent main window; if it is null, the tool manager's main window is used |
vis | show toolbar visible immediately after creation (true by default) |
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 |
||
) |
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).
title | toolbar title |
name | toolbar name (identifier) |
floatable | if true , new toolbar is made floatable |
dockAreas | dock areas of the main window where the new toolbar can be situated |
tid | requested toolbar ID |
mw | parent main window; if it is null, the tool manager's main window is used |
vis | show toolbar visible immediately after creation (true by default) |
References find(), mainWindow(), myToolBars, onToolBarDestroyed(), and QtxActionToolMgr::ToolBarInfo::toolBar.
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).
title | toolbar title |
name | toolbar name (identifier) |
tid | requested toolbar ID |
mw | parent main window; if it is null, the tool manager's main window is used |
vis | show toolbar visible immediately after creation (true by default) |
References createToolBar().
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.
title | toolbar title |
tid | requested toolbar ID |
mw | parent main window; if it is null, the tool manager's main window is used |
vis | show toolbar visible immediately after creation (true by default) |
|
protected |
Search toolbar by given name.
title | toolbar title |
References myToolBars.
|
protected |
Search toolbar with given title owned by main window \mw.
title | toolbar title |
mw | main window |
int QtxActionToolMgr::find | ( | QToolBar * | tb | ) | const |
Get toolbar identifier.
tb | toolbar |
References myToolBars.
bool QtxActionToolMgr::hasToolBar | ( | const int | tid | ) | const |
Check if toolbar with given id already registered.
tid | toolbar ID |
true
if toolbar is registered in the toolbar manager References myToolBars.
bool QtxActionToolMgr::hasToolBar | ( | const QString & | title | ) | const |
Check if toolbar with given id already registered.
title | toolbar title |
true
if toolbar is registered in the toolbar manager References find().
void QtxActionToolMgr::hide | ( | const int | id | ) |
int QtxActionToolMgr::index | ( | const int | id, |
const int | tid | ||
) | const |
Get index of the action id within the toolbar tid.
id | action ID |
tid | toolbar ID |
References myToolBars.
int QtxActionToolMgr::insert | ( | const int | id, |
const int | tid, | ||
const int | idx = -1 |
||
) |
Insert action into toolbar.
id | action ID |
tid | toolbar ID |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References QtxActionMgr::contains(), hasToolBar(), index(), myToolBars, and QtxActionMgr::triggerUpdate().
int QtxActionToolMgr::insert | ( | const int | id, |
const QString & | title, | ||
const int | idx = -1 |
||
) |
Insert action into toolbar.
id | action ID |
title | toolbar title |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References createToolBar(), and insert().
int QtxActionToolMgr::insert | ( | QAction * | a, |
const int | tid, | ||
const int | idx = -1 |
||
) |
Insert action into toolbar.
a | action |
tid | toolbar ID |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References insert(), and QtxActionMgr::registerAction().
int QtxActionToolMgr::insert | ( | QAction * | a, |
const QString & | title, | ||
const int | idx = -1 |
||
) |
Insert action into toolbar.
a | action |
title | toolbar title |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References createToolBar(), insert(), and QtxActionMgr::registerAction().
|
protectedvirtual |
Update all registered toolbars.
Reimplemented from QtxActionMgr.
References QtxActionMgr::isUpdatesEnabled(), myToolBars, myUpdateIds, and updateToolBar().
bool QtxActionToolMgr::isShown | ( | const int | id | ) | const |
Get visibility status for toolbar action with given id.
id | action ID |
true
if action is shown in all toolbars References QtxActionToolMgr::ToolNode::id, and myToolBars.
|
virtual |
Check if an action with given id is visible in the toolbar tid.
id | action ID |
tid | toolbar ID |
true
if action is shown in the toolbar Reimplemented from QtxActionMgr.
References QtxActionToolMgr::ToolNode::id, myToolBars, QtxActionToolMgr::ToolBarInfo::nodes, and QtxActionToolMgr::ToolNode::visible.
|
virtual |
Load toolbar contents from the file.
fname | file name |
r | actions reader |
true
on success and false
on error References QtxActionMgr::Reader::read().
QMainWindow * QtxActionToolMgr::mainWindow | ( | ) | const |
|
protectedslot |
Called when toolbar is destroyed.
Clears internal pointer to the toolbar to disable crashes.
References find(), and myToolBars.
int QtxActionToolMgr::prepend | ( | const int | id, |
const int | tid | ||
) |
Insert action to the beginning of toolbar.
id | action ID |
tid | toolbar ID |
References insert().
int QtxActionToolMgr::prepend | ( | const int | id, |
const QString & | title | ||
) |
Insert action to the beginning of toolbar.
id | action ID |
title | toolbar title |
References insert().
int QtxActionToolMgr::prepend | ( | QAction * | a, |
const int | tid | ||
) |
Insert action to the beginning of toolbar.
a | action |
tid | toolbar ID |
References insert().
int QtxActionToolMgr::prepend | ( | QAction * | a, |
const QString & | title | ||
) |
Insert action to the beginning of toolbar.
a | action ID |
title | toolbar title |
References insert().
void QtxActionToolMgr::remove | ( | const int | id, |
const int | tid | ||
) |
Remove action from toolbar.
id | action ID |
tid | toolbar ID |
References myToolBars, and QtxActionMgr::triggerUpdate().
void QtxActionToolMgr::remove | ( | const int | id, |
const QString & | title | ||
) |
void QtxActionToolMgr::removeToolBar | ( | const int | tid | ) |
void QtxActionToolMgr::removeToolBar | ( | const QString & | title | ) |
void QtxActionToolMgr::setShown | ( | const int | id, |
const bool | on | ||
) |
Set visibility status for toolbar action with given id.
id | action ID |
on | new visibility status |
References myToolBars, and setVisible().
|
virtual |
Show/hide action with given id in the toolbar tid.
id | action ID |
tid | toolbar ID |
on | new visibility status |
Reimplemented from QtxActionMgr.
References QtxActionToolMgr::ToolNode::id, myToolBars, QtxActionMgr::triggerUpdate(), updateContent(), and QtxActionToolMgr::ToolNode::visible.
void QtxActionToolMgr::show | ( | const int | id | ) |
|
private |
Remove extra separators from the toolbar.
tb | toolbar |
References Qtx::simplifySeparators().
QToolBar * QtxActionToolMgr::toolBar | ( | const int | tid | ) | const |
Get toolbar by given tid.
tid | toolbar ID |
References myToolBars.
QToolBar * QtxActionToolMgr::toolBar | ( | const QString & | title | ) | const |
QIntList QtxActionToolMgr::toolBarsIds | ( | ) | const |
|
private |
Perform delayed toolbar update.
tid | toolbar ID |
References myUpdateIds, and QtxActionMgr::triggerUpdate().
|
protectedvirtual |
Called when delayed content update is performed.
Customizes the content update operation.
Reimplemented from QtxActionMgr.
References QtxActionMgr::isUpdatesEnabled(), myUpdateIds, and updateToolBar().
|
protected |
Update toolbar.
tid | toolbar ID |
References QtxActionMgr::action(), QtxActionMgr::isUpdatesEnabled(), isVisible(), myToolBars, and simplifySeparators().
|
private |
parent main window
|
private |
toobars map
|
private |
list of actions ID being updated