Toolbar actions manager. More...
#include <QtxActionToolMgr.h>

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. | |
| QMainWindow * | mainWindow () 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. | |
| QToolBar * | toolBar (const int) const |
| Get toolbar by given tid. | |
| QToolBar * | toolBar (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. | |
| QAction * | action (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 QAction * | separator (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. | |
| QToolBar * | find (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< ToolNode > | NodeList |
| toolbar nodes list | |
| typedef QMap< int, ToolBarInfo > | ToolBarMap |
| 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 | |
| QMainWindow * | myMainWindow |
| parent main window | |
| QMap< int, int > | myUpdateIds |
| list of actions ID being updated | |
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.
typedef QList<ToolNode> QtxActionToolMgr.NodeList [private] |
typedef QMap<int, ToolBarInfo> QtxActionToolMgr.ToolBarMap [private] |
| QtxActionToolMgr::QtxActionToolMgr | ( | QMainWindow * | p | ) |
| p | parent main window |
| QtxActionToolMgr::~QtxActionToolMgr | ( | ) | [virtual] |
| QMainWindow * QtxActionToolMgr::mainWindow | ( | ) | const |
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.
| 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, |
| 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 find(), mainWindow(), myToolBars, onToolBarDestroyed(), and QtxActionToolMgr.ToolBarInfo.toolBar.
| void QtxActionToolMgr::removeToolBar | ( | const QString & | title | ) |
| title | toolbar title |
References find().
| void QtxActionToolMgr::removeToolBar | ( | const int | tid | ) |
| tid | toolbar ID |
References myToolBars.
| int QtxActionToolMgr::insert | ( | const int | id, |
| const int | tid, | ||
| const int | idx = -1 |
||
| ) |
| 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 | ( | QAction * | a, |
| const int | tid, | ||
| const int | idx = -1 |
||
| ) |
| 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 | ( | const int | id, |
| const QString & | title, | ||
| const int | idx = -1 |
||
| ) |
| 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 QString & | title, | ||
| const int | idx = -1 |
||
| ) |
| 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().
| int QtxActionToolMgr::append | ( | const int | id, |
| const int | tid | ||
| ) |
| int QtxActionToolMgr::append | ( | QAction * | a, |
| const int | tid | ||
| ) |
| int QtxActionToolMgr::append | ( | const int | id, |
| const QString & | title | ||
| ) |
| int QtxActionToolMgr::append | ( | QAction * | a, |
| const QString & | title | ||
| ) |
| int QtxActionToolMgr::prepend | ( | const int | id, |
| const int | tid | ||
| ) |
| int QtxActionToolMgr::prepend | ( | QAction * | a, |
| const int | tid | ||
| ) |
| int QtxActionToolMgr::prepend | ( | const int | id, |
| const QString & | title | ||
| ) |
| int QtxActionToolMgr::prepend | ( | QAction * | a, |
| const QString & | title | ||
| ) |
| bool QtxActionToolMgr::isVisible | ( | const int | id, |
| const int | tid | ||
| ) | const [virtual] |
| 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.
| void QtxActionToolMgr::setVisible | ( | const int | id, |
| const int | tid, | ||
| const bool | on | ||
| ) | [virtual] |
| id | action ID |
| tid | toolbar ID |
| on | new visibility status |
Reimplemented from QtxActionMgr.
References QtxActionToolMgr.ToolNode.id, myToolBars, QtxActionMgr.triggerUpdate(), and QtxActionToolMgr.ToolNode.visible.
| void QtxActionToolMgr::show | ( | const int | id | ) |
| id | action ID |
References setShown().
| void QtxActionToolMgr::hide | ( | const int | id | ) |
| id | action ID |
References setShown().
| bool QtxActionToolMgr::isShown | ( | const int | id | ) | const |
| id | action ID |
true if action is shown in all toolbars References QtxActionToolMgr.ToolNode.id, and myToolBars.
| void QtxActionToolMgr::setShown | ( | const int | id, |
| const bool | on | ||
| ) |
| id | action ID |
| on | new visibility status |
References myToolBars, and setVisible().
| void QtxActionToolMgr::remove | ( | const int | id, |
| const int | tid | ||
| ) |
| id | action ID |
| tid | toolbar ID |
References myToolBars, and QtxActionMgr.triggerUpdate().
| void QtxActionToolMgr::remove | ( | const int | id, |
| const QString & | title | ||
| ) |
| id | action ID |
| title | toolbar title |
References find().
| QToolBar * QtxActionToolMgr::toolBar | ( | const int | tid | ) | const |
| QToolBar * QtxActionToolMgr::toolBar | ( | const QString & | title | ) | const |
| QIntList QtxActionToolMgr::toolBarsIds | ( | ) | const |
| 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().
| bool QtxActionToolMgr::containsAction | ( | const int | id, |
| const int | tid = -1 |
||
| ) | const |
| id | action ID |
| tid | toolbar ID |
true if toolbar contains action References myToolBars.
| int QtxActionToolMgr::index | ( | const int | id, |
| const int | tid | ||
| ) | const |
| id | action ID |
| tid | toolbar ID |
References myToolBars.
| bool QtxActionToolMgr::load | ( | const QString & | fname, |
| QtxActionMgr::Reader & | r | ||
| ) | [virtual] |
| fname | file name |
| r | actions reader |
true on success and false on error References QtxActionMgr.Reader.read().
| int QtxActionToolMgr::find | ( | QToolBar * | tb | ) | const |
| 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] |
| QToolBar * QtxActionToolMgr::find | ( | const QString & | title, |
| QMainWindow * | mw | ||
| ) | const [protected] |
| title | toolbar title |
| mw | main window |
| void QtxActionToolMgr::internalUpdate | ( | ) | [protected, virtual] |
Reimplemented from QtxActionMgr.
References QtxActionMgr.isUpdatesEnabled(), myToolBars, myUpdateIds, and updateToolBar().
| void QtxActionToolMgr::updateToolBar | ( | const int | tid | ) | [protected] |
| tid | toolbar ID |
References test_table.a, QtxActionMgr.action(), QtxActionMgr.isUpdatesEnabled(), isVisible(), myToolBars, and simplifySeparators().
| 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] |
| tb | toolbar |
| void QtxActionToolMgr::triggerUpdate | ( | const int | tid | ) | [private] |
| tid | toolbar 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.
| a | action to be registered |
| userId | action ID |
References QtxActionMgr.actionId(), QtxActionMgr.contains(), QtxActionMgr.generateId(), QtxActionMgr.myActions, and QtxActionMgr.unRegisterAction().
| void QtxActionMgr::unRegisterAction | ( | const int | id | ) | [virtual, inherited] |
| id | action ID |
Reimplemented in QtxPopupMgr.
References QtxActionMgr.contains(), and QtxActionMgr.myActions.
| QAction * QtxActionMgr::action | ( | const int | id | ) | const [inherited] |
| id | action ID |
References QtxActionMgr.contains(), and QtxActionMgr.myActions.
| int QtxActionMgr::actionId | ( | const QAction * | a | ) | const [inherited] |
| a | action |
References test_table.a, and QtxActionMgr.myActions.
| bool QtxActionMgr::contains | ( | const int | id | ) | const [inherited] |
| id | action ID |
true if internal map contains action with such identifier References QtxActionMgr.myActions.
| int QtxActionMgr::count | ( | ) | const [inherited] |
| bool QtxActionMgr::isEmpty | ( | ) | const [inherited] |
| QIntList QtxActionMgr::idList | ( | ) | const [inherited] |
References QtxActionMgr.myActions.
| bool QtxActionMgr::isUpdatesEnabled | ( | ) | const [inherited] |
true if update is enabled References QtxActionMgr.myUpdate.
| void QtxActionMgr::setUpdatesEnabled | ( | const bool | upd | ) | [virtual, inherited] |
| void QtxActionMgr::update | ( | ) | [inherited] |
Calls virtual function internalUpdate to update the contents. Does nothing if update is disabled.
References QtxActionMgr.internalUpdate(), QtxActionMgr.isUpdatesEnabled(), and QtxActionMgr.myUpdTimer.
| bool QtxActionMgr::isEnabled | ( | const int | id | ) | const [virtual, inherited] |
| id | action ID |
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.
| id | action ID |
| enable | new 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.
| own | ownership flag |
References test_table.a, and qtxSeparatorActionCleanup().
| int QtxActionMgr::generateId | ( | ) | const [protected, inherited] |
| void QtxActionMgr::triggerUpdate | ( | ) | [protected, inherited] |
Does nothing if update is disabled.
References QtxActionMgr.isUpdatesEnabled(), QtxActionMgr.myUpdTimer, and QtxActionMgr.onUpdateContent().
ToolBarMap QtxActionToolMgr.myToolBars [private] |
QMainWindow* QtxActionToolMgr.myMainWindow [private] |
QMap<int,int> QtxActionToolMgr.myUpdateIds [private] |