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... | |
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 . 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< 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 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 |
|
private |
QtxActionToolMgr::QtxActionToolMgr | ( | QMainWindow * | p | ) |
p | parent main window |
|
virtual |
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.
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) |
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).
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, |
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.
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 |
||
) |
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::find | ( | QToolBar * | tb | ) | const |
|
protected |
|
protected |
title | toolbar title |
mw | main window |
bool QtxActionToolMgr::hasToolBar | ( | const int | tid | ) | const |
tid | toolbar ID |
true
if toolbar is registered in the toolbar manager References myToolBars.
bool QtxActionToolMgr::hasToolBar | ( | const QString & | title | ) | const |
title | toolbar title |
true
if toolbar is registered in the toolbar manager References find().
void QtxActionToolMgr::hide | ( | const int | id | ) |
id | action ID |
References setShown().
id | action ID |
tid | toolbar ID |
References myToolBars.
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().
a | action |
tid | toolbar ID |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References insert(), and QtxActionMgr::registerAction().
id | action ID |
title | toolbar title |
idx | action index in the toolbar (if < 0, action is appended to the end) |
References createToolBar(), and insert().
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 |
Reimplemented from QtxActionMgr.
References QtxActionMgr::isUpdatesEnabled(), myToolBars, myUpdateIds, and updateToolBar().
bool QtxActionToolMgr::isShown | ( | const int | id | ) | const |
id | action ID |
true
if action is shown in all toolbars References QtxActionToolMgr::ToolNode::id, and myToolBars.
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 |
fname | file name |
r | actions reader |
true
on success and false
on error References QtxActionMgr::Reader::read().
QMainWindow * QtxActionToolMgr::mainWindow | ( | ) | const |
References myMainWindow.
|
protectedslot |
Clears internal pointer to the toolbar to disable crashes.
References find(), and myToolBars.
id | action ID |
tid | toolbar ID |
References myToolBars, and QtxActionMgr::triggerUpdate().
id | action ID |
title | toolbar title |
References find().
void QtxActionToolMgr::removeToolBar | ( | const QString & | title | ) |
title | toolbar title |
References find().
void QtxActionToolMgr::removeToolBar | ( | const int | tid | ) |
tid | toolbar ID |
References myToolBars.
id | action ID |
on | new visibility status |
References myToolBars, and setVisible().
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 | ) |
id | action ID |
References setShown().
|
private |
tb | toolbar |
References Qtx::simplifySeparators().
QIntList QtxActionToolMgr::toolBarsIds | ( | ) | const |
|
private |
tid | toolbar ID |
References myUpdateIds, and QtxActionMgr::triggerUpdate().
|
protectedvirtual |
Customizes the content update operation.
Reimplemented from QtxActionMgr.
References QtxActionMgr::isUpdatesEnabled(), myUpdateIds, and updateToolBar().
|
protected |
tid | toolbar ID |
References QtxActionMgr::action(), QtxActionMgr::isUpdatesEnabled(), isVisible(), myToolBars, and simplifySeparators().
|
private |
|
private |
|
private |