#include "CAM_Study.h"
#include <QtxAction.h>
+#include <QtxActionMgrId.h>
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
This protected method allows derived module classes to set application object
from methods different from initalize(). This is used e.g. when
- a module instance is created but not intialized by custom application class,
+ a module instance is created but not intialized by custom application class,
still the module needs some minimal link to application.
\sa initialize()
*/
myActionMap.insert( ident, a );
if ( menuMgr() )
- menuMgr()->registerAction( a );
+ menuMgr()->registerAction( a, QtxActionMgrId( ident, moduleName() ) );
if ( toolMgr() )
- toolMgr()->registerAction( a );
+ toolMgr()->registerAction( a, QtxActionMgrId( ident, moduleName() ) );
if ( application() && application()->desktop() )
application()->desktop()->addAction( a );
{
QtxActionToolMgr* mgr = toolMgr();
myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) );
- mgr->append( DumpId, myToolBar );
- mgr->append( ScaleOpId, myToolBar );
- mgr->append( MoveOpId, myToolBar );
- mgr->append( toolMgr()->separator(), myToolBar );
- mgr->append( CurvPointsId, myToolBar );
- mgr->append( CurvLinesId, myToolBar );
- mgr->append( CurvSplinesId, myToolBar );
- mgr->append( toolMgr()->separator(), myToolBar );
- mgr->append( PModeXLinearId, myToolBar );
- mgr->append( PModeXLogarithmicId, myToolBar );
- mgr->append( toolMgr()->separator(), myToolBar );
- mgr->append( PModeYLinearId, myToolBar );
- mgr->append( PModeYLogarithmicId, myToolBar );
- mgr->append( toolMgr()->separator(), myToolBar );
- mgr->append( LegendId, myToolBar );
- mgr->append( CurvSettingsId, myToolBar );
- mgr->append( CloneId, myToolBar );
- mgr->append( PrintId, myToolBar );
+ mgr->insert( DumpId, myToolBar );
+ mgr->insert( ScaleOpId, myToolBar );
+ mgr->insert( MoveOpId, myToolBar );
+ mgr->insert( toolMgr()->separator(), myToolBar );
+ mgr->insert( CurvPointsId, myToolBar );
+ mgr->insert( CurvLinesId, myToolBar );
+ mgr->insert( CurvSplinesId, myToolBar );
+ mgr->insert( toolMgr()->separator(), myToolBar );
+ mgr->insert( PModeXLinearId, myToolBar );
+ mgr->insert( PModeXLogarithmicId, myToolBar );
+ mgr->insert( toolMgr()->separator(), myToolBar );
+ mgr->insert( PModeYLinearId, myToolBar );
+ mgr->insert( PModeYLogarithmicId, myToolBar );
+ mgr->insert( toolMgr()->separator(), myToolBar );
+ mgr->insert( LegendId, myToolBar );
+ mgr->insert( CurvSettingsId, myToolBar );
+ mgr->insert( CloneId, myToolBar );
+ mgr->insert( PrintId, myToolBar );
}
/*!
{
public:
MenuNode();
- MenuNode( MenuNode*, const int, const int, const int );
+ MenuNode( MenuNode*, const QtxActionMgrId&, const int, const int );
~MenuNode();
- MenuNode* parent; //!< parent menu node
- int id; //!< menu nodeID
- int idx; //!< menu node index
- int group; //!< menu group ID
- bool visible; //!< visibility status
- int emptyEnabled; //!< enable empty menu flag
- NodeList children; //!< children menu nodes list
+ MenuNode* parent; //!< parent menu node
+ QtxActionMgrId id; //!< menu nodeID
+ int idx; //!< menu node index
+ int group; //!< menu group ID
+ bool visible; //!< visibility status
+ int emptyEnabled; //!< enable empty menu flag
+ NodeList children; //!< children menu nodes list
};
/*!
\internal
*/
QtxActionMenuMgr::MenuNode::MenuNode()
- : parent( 0 ), id( -1 ), idx( -1 ), group( -1 ), visible( true ), emptyEnabled( 0 )
+ : parent( 0 ),
+ id( QtxActionMgrId() ),
+ idx( -1 ),
+ group( -1 ),
+ visible( true ),
+ emptyEnabled( 0 )
{
}
\param _idx menu node index
\param _group menu node group ID
*/
-QtxActionMenuMgr::MenuNode::MenuNode( MenuNode* p,
- const int _id,
- const int _idx,
- const int _group )
-: parent( p ), id( _id ), idx( _idx ), group( _group ), visible( true ), emptyEnabled( 0 )
+QtxActionMenuMgr::MenuNode::MenuNode( MenuNode* p, const QtxActionMgrId& _id,
+ const int _idx, const int _group )
+: parent( p ),
+ id( _id ),
+ idx( _idx ),
+ group( _group ),
+ visible( true ),
+ emptyEnabled( 0 )
{
if ( p )
p->children.append( this );
\return \c true if an action is visible to the parent
\sa setVisible()
*/
-bool QtxActionMenuMgr::isVisible( const int actId, const int place ) const
+bool QtxActionMenuMgr::isVisible( const QtxActionMgrId& actId, const QtxActionMgrId& place ) const
{
MenuNode* node = find( actId, place );
return node && node->visible;
\param v new visibility state
\sa isVisible()
*/
-void QtxActionMenuMgr::setVisible( const int actId, const int place, const bool v )
+void QtxActionMenuMgr::setVisible( const QtxActionMgrId& actId, const QtxActionMgrId& place, const bool v )
{
MenuNode* node = find( actId, place );
if ( node )
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const int id, const QString& menus, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QtxActionMgrId& id, const QString& menus, const int group, const int idx )
{
return insert( id, menus.split( "|", QString::SkipEmptyParts ), group, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( QAction* a, const QString& menus, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( QAction* a, const QString& menus, const int group, const int idx )
{
return insert( a, menus.split( "|", QString::SkipEmptyParts ), group, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const int id, const QStringList& menus, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QtxActionMgrId& id, const QStringList& menus,
+ const int group, const int idx )
{
- int pId = createMenu( menus, -1 );
- if ( pId == -1 )
- return -1;
+ QtxActionMgrId pId = createMenu( menus, -1 );
+ if ( pId.isNull() )
+ return QtxActionMgrId();
return insert( id, pId, group, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( QAction* a, const QStringList& menus, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( QAction* a, const QStringList& menus, const int group, const int idx )
{
- int pId = createMenu( menus, -1 );
- if ( pId == -1 )
- return -1;
+ QtxActionMgrId pId = createMenu( menus, -1 );
+ if ( pId.isNull() )
+ return QtxActionMgrId();
return insert( a, pId, group, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const int id, const int pId, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QtxActionMgrId& id, const QtxActionMgrId& pId,
+ const int group, const int idx )
{
- if ( id == -1 )
- return -1;
+ if ( id.isNull() )
+ return QtxActionMgrId();
- MenuNode* pNode = pId == -1 ? myRoot : find( pId );
+ MenuNode* pNode = pId.isNull() ? myRoot : find( pId );
if ( !pNode )
- return -1;
+ return QtxActionMgrId();
MenuNode* node = new MenuNode( pNode, id, idx, group );
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( QAction* a, const int pId, const int group, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( QAction* a, const QtxActionMgrId& pId,
+ const int group, const int idx )
{
return insert( registerAction( a ), pId, group, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const QString& title, const int pId, const int group, const int id, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QString& title, const QtxActionMgrId& pId,
+ const int group, const QtxActionMgrId& id, const int idx )
{
- MenuNode* pNode = pId == -1 ? myRoot : find( pId );
+ MenuNode* pNode = pId.isNull() ? myRoot : find( pId );
if ( !pNode )
- return -1;
+ return QtxActionMgrId();
- MenuNode* eNode = id == -1 ? 0 : find( id );
+ MenuNode* eNode = id.isNull() ? 0 : find( id );
- int fid = -1;
- for ( NodeList::iterator it = pNode->children.begin(); it != pNode->children.end() && fid == -1; ++it )
+ QtxActionMgrId fid;
+ for ( NodeList::iterator it = pNode->children.begin(); it != pNode->children.end() && fid.isNull(); ++it )
{
if ( myMenus.contains( (*it)->id ) &&
clearTitle( myMenus[(*it)->id]->text() ) == clearTitle( title ) )
fid = (*it)->id;
}
- if ( fid != -1 )
+ if ( !fid.isNull() )
return fid;
- int gid = (id == -1 || eNode ) ? generateId() : id;
+ QtxActionMgrId gid = ( id.isNull() || eNode ) ? generateId() : id;
QtxMenu* menu = new QtxMenu( 0 );
QAction* ma = menu->menuAction();
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const QString& title, const QString& menus, const int group, const int id, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QString& title, const QString& menus,
+ const int group, const QtxActionMgrId& id, const int idx )
{
return insert( title, menus.split( "|", QString::SkipEmptyParts ), group, id, idx );
}
\param idx menu index inside the menu group
\return action ID
*/
-int QtxActionMenuMgr::insert( const QString& title, const QStringList& menus, const int group, const int id, const int idx )
+QtxActionMgrId QtxActionMenuMgr::insert( const QString& title, const QStringList& menus,
+ const int group, const QtxActionMgrId& id, const int idx )
{
- int pId = createMenu( menus, -1 );
+ QtxActionMgrId pId = createMenu( menus, -1 );
return insert( title, pId, group, id, idx );
}
-/*!
- \brief Create and add menu item action to the end of menu.
- \param title menu text
- \param pId parent menu action ID
- \param group group ID
- \param id action ID
- \return action ID
-*/
-int QtxActionMenuMgr::append( const QString& title, const int pId, const int group, const int id )
-{
- return insert( title, pId, group, id );
-}
-
-/*!
- \brief Create and add menu item action to the end of menu.
- \param id action ID
- \param pId parent menu action ID
- \param group group ID
- \return action ID
-*/
-int QtxActionMenuMgr::append( const int id, const int pId, const int group )
-{
- return insert( id, pId, group );
-}
-
-/*!
- \brief Create and add menu item action to the end of menu.
- \param a action
- \param pId parent menu action ID
- \param group group ID
- \return action ID
-*/
-int QtxActionMenuMgr::append( QAction* a, const int pId, const int group )
-{
- return insert( a, pId, group );
-}
-
-/*!
- \brief Create and add menu item action to the beginning of menu.
- \param title menu text
- \param pId parent menu action ID
- \param group group ID
- \param id action ID
- \return action ID
-*/
-int QtxActionMenuMgr::prepend( const QString& title, const int pId, const int group, const int id )
-{
- return insert( title, pId, group, id, 0 );
-}
-
-/*!
- \brief Create and add menu item action to the beginning of menu.
- \param id action ID
- \param pId parent menu action ID
- \param group group ID
- \return action ID
-*/
-int QtxActionMenuMgr::prepend( const int id, const int pId, const int group )
-{
- return insert( id, pId, group, 0 );
-}
-
-/*!
- \brief Create and add menu item action to the beginning of menu.
- \param a action
- \param pId parent menu action ID
- \param group group ID
- \return action ID
-*/
-int QtxActionMenuMgr::prepend( QAction* a, const int pId, const int group )
-{
- return insert( a, pId, group, 0 );
-}
-
/*!
\brief Remove menu item with given \a id.
\param id menu action ID
*/
-void QtxActionMenuMgr::remove( const int id )
+void QtxActionMenuMgr::remove( const QtxActionMgrId& id )
{
removeMenu( id, 0 );
update();
\param pId parent menu action ID
\param group group ID
*/
-void QtxActionMenuMgr::remove( const int id, const int pId, const int group )
+void QtxActionMenuMgr::remove( const QtxActionMgrId& id, const QtxActionMgrId& pId, const int group )
{
- MenuNode* pNode = pId == -1 ? myRoot : find( pId );
+ MenuNode* pNode = pId.isNull() ? myRoot : find( pId );
if ( !pNode )
return;
triggerUpdate( pNode->id, false );
}
-/*!
- \brief Show menu item with given \a id.
- \param id menu action ID
- \sa hide()
-*/
-void QtxActionMenuMgr::show( const int id )
-{
- setShown( id, true );
-}
-
-/*!
- \brief Hide menu item with given \a id.
- \param id menu action ID
- \sa show()
-*/
-void QtxActionMenuMgr::hide( const int id )
-{
- setShown( id, false );
-}
-
/*!
\brief Get visibility status for menu item with given \a id.
\param id menu action ID
\return \c true if an item is shown
\sa setShown()
*/
-bool QtxActionMenuMgr::isShown( const int id ) const
+bool QtxActionMenuMgr::isShown( const QtxActionMgrId& id ) const
{
bool res = false;
MenuNode* node = find( id );
\param on new visibility status
\sa isShown()
*/
-void QtxActionMenuMgr::setShown( const int id, const bool on )
+void QtxActionMenuMgr::setShown( const QtxActionMgrId& id, const bool on )
{
NodeList aNodes;
find( id, aNodes );
\param id menu action ID
\param title new menu title
*/
-void QtxActionMenuMgr::change( const int id, const QString& title )
+void QtxActionMenuMgr::change( const QtxActionMgrId& id, const QString& title )
{
QAction* a = menuAction( id );
if ( a )
\param rec if \c true perform recursive search
\return menu node or 0 if it is not found
*/
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, const int pId, const bool rec ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QtxActionMgrId& id,
+ const QtxActionMgrId& pId, const bool rec ) const
{
return find( id, find( pId ), rec );
}
\param rec if \c true perform recursive search
\return menu node or 0 if it is not found
*/
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const int id, MenuNode* startNode, const bool rec ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QtxActionMgrId& id, MenuNode* startNode, const bool rec ) const
{
MenuNode* node = 0;
MenuNode* start = startNode ? startNode : myRoot;
\param startNode start menu node (if 0, search from root node)
\return \c true if at least one node is found
*/
-bool QtxActionMenuMgr::find( const int id, NodeList& lst, MenuNode* startNode ) const
+bool QtxActionMenuMgr::find( const QtxActionMgrId& id, NodeList& lst, MenuNode* startNode ) const
{
MenuNode* start = startNode ? startNode : myRoot;
for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
\param rec if \c true perform recursive search
\return menu node or 0 if it is not found
*/
-QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const int pId, const bool rec ) const
+QtxActionMenuMgr::MenuNode* QtxActionMenuMgr::find( const QString& title, const QtxActionMgrId& pId, const bool rec ) const
{
return find( title, find( pId ), rec );
}
\param pid parent meun item ID
\return id (>0) on success or -1 if menu item is not found
*/
-int QtxActionMenuMgr::findId( const int id, const int pid ) const
+QtxActionMgrId QtxActionMenuMgr::findId( const QtxActionMgrId& id, const QtxActionMgrId& pid ) const
{
- MenuNode* start = pid != -1 ? find( pid ) : myRoot;
+ MenuNode* start = !pid.isNull() ? find( pid ) : myRoot;
if ( start )
{
for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
return id;
}
}
- return -1;
+ return QtxActionMgrId();
}
/*!
\param id menu action ID
\param startNode parent menu node which search starts from (if 0, search starts from root)
*/
-void QtxActionMenuMgr::removeMenu( const int id, MenuNode* startNode )
+void QtxActionMenuMgr::removeMenu( const QtxActionMgrId& id, MenuNode* startNode )
{
MenuNode* start = startNode ? startNode : myRoot;
for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
\param id action ID
\return action or 0 if \a id is invalid
*/
-QAction* QtxActionMenuMgr::itemAction( const int id ) const
+QAction* QtxActionMenuMgr::itemAction( const QtxActionMgrId& id ) const
{
return action( id );
}
\param id submenu ID
\return submenu action or 0 if action is not found
*/
-QAction* QtxActionMenuMgr::menuAction( const int id ) const
+QAction* QtxActionMenuMgr::menuAction( const QtxActionMgrId& id ) const
{
QAction* a = 0;
\param id submenu ID
\return submenu action or 0 if it is not found
*/
-int QtxActionMenuMgr::menuActionId( QAction* a ) const
+QtxActionMgrId QtxActionMenuMgr::menuActionId( QAction* a ) const
{
- int id = -1;
- for ( MenuMap::ConstIterator itr = myMenus.begin(); itr != myMenus.end() && id == -1; ++itr )
+ QtxActionMgrId id;
+ for ( MenuMap::ConstIterator itr = myMenus.begin(); itr != myMenus.end() && id.isNull(); ++itr )
{
if ( itr.value() == a )
id = itr.key();
updateMenu( node, rec, false );
MenuNode* par = node->parent;
- if ( !isVisible( node->id, par ? par->id : -1 ) )
+ if ( !isVisible( node->id, par ? par->id : QtxActionMgrId() ) )
continue;
bool isMenu = false;
\param pId parent menu item ID
\return created menu item ID (last in the chain)
*/
-int QtxActionMenuMgr::createMenu( const QStringList& lst, const int pId )
+QtxActionMgrId QtxActionMenuMgr::createMenu( const QStringList& lst, const QtxActionMgrId& pId )
{
if ( lst.isEmpty() )
- return -1;
+ return QtxActionMgrId();
QStringList sl( lst );
QString title = sl.last().trimmed();
sl.removeLast();
- int parentId = sl.isEmpty() ? pId : createMenu( sl, pId );
+ QtxActionMgrId parentId = sl.isEmpty() ? pId : createMenu( sl, pId );
return insert( title, parentId, -1 );
}
\param pid parent menu item ID
\return \c true if parent menu item contains such child item
*/
-bool QtxActionMenuMgr::containsMenu( const QString& title, const int pid, const bool rec ) const
+bool QtxActionMenuMgr::containsMenu( const QString& title, const QtxActionMgrId& pid, const bool rec ) const
{
return (bool)find( title, pid, rec );
}
\param pid parent menu item ID
\return \c true if parent menu item contains such child item
*/
-bool QtxActionMenuMgr::containsMenu( const int id, const int pid, const bool rec ) const
+bool QtxActionMenuMgr::containsMenu( const QtxActionMgrId& id, const QtxActionMgrId& pid, const bool rec ) const
{
return (bool)find( id, pid, rec );
}
\param id menu item ID
\return menu pointer or 0 if menu is not found
*/
-QMenu* QtxActionMenuMgr::findMenu( const int id ) const
+QMenu* QtxActionMenuMgr::findMenu( const QtxActionMgrId& id ) const
{
QMenu* m = 0;
QAction* a = menuAction( id );
\param rec if \c true, perform recursive update
\return menu pointer or 0 if menu is not found
*/
-QMenu* QtxActionMenuMgr::findMenu( const QString& title, const int pid, const bool rec ) const
+QMenu* QtxActionMenuMgr::findMenu( const QString& title, const QtxActionMgrId& pid, const bool rec ) const
{
QMenu* m = 0;
MenuNode* node = find( title, pid, rec );
\param id menu item ID
\return \c true if empty menu is enabled
*/
-bool QtxActionMenuMgr::isEmptyEnabled( const int id ) const
+bool QtxActionMenuMgr::isEmptyEnabled( const QtxActionMgrId& id ) const
{
MenuNode* node = find( id );
if ( node && menuAction( id ) )
\param id menu item ID
\param enable if \c true, empty menu will be enabled, otherwise empty menu will be disabled
*/
-void QtxActionMenuMgr::setEmptyEnabled( const int id, const bool enable )
+void QtxActionMenuMgr::setEmptyEnabled( const QtxActionMgrId& id, const bool enable )
{
MenuNode* node = find( id );
if ( node && menuAction( id ) ) {
\brief Returns the priority for specified menu.
\param id - menu id.
*/
-int QtxActionMenuMgr::menuPriority( const int id ) const
+int QtxActionMenuMgr::menuPriority( const QtxActionMgrId& id ) const
{
return QtxMenu::actionPriority( menuAction( id ) );
}
\param id - menu id.
\param p - priority value.
*/
-void QtxActionMenuMgr::setMenuPriority( const int id, const int p )
+void QtxActionMenuMgr::setMenuPriority( const QtxActionMgrId& id, const int p )
{
return QtxMenu::setActionPriority( menuAction( id ), p );
}
-bool QtxActionMenuMgr::isPermanentMenu( const int id ) const
+bool QtxActionMenuMgr::isPermanentMenu( const QtxActionMgrId& id ) const
{
return QtxMenu::isPermanentAction( menuAction( id ) );
}
-void QtxActionMenuMgr::setPermanentMenu( const int id, bool on )
+void QtxActionMenuMgr::setPermanentMenu( const QtxActionMgrId& id, bool on )
{
QtxMenu::setPermanentAction( menuAction( id ), on );
}
\param id menu item ID
\param rec if \c true, perform recursive update
*/
-void QtxActionMenuMgr::triggerUpdate( const int id, const bool rec )
+void QtxActionMenuMgr::triggerUpdate( const QtxActionMgrId& id, const bool rec )
{
bool isRec = rec;
if ( myUpdateIds.contains( id ) )
- isRec = isRec || myUpdateIds[ id ];
+ isRec = isRec || myUpdateIds[id];
myUpdateIds.insert( id, isRec );
QtxActionMgr::triggerUpdate();
// have positive identifiers this method might not work correctly. In this case it would be
// necessary to improve this method and to add preliminary sorting a submenus by depth of an
// enclosure.
- for ( QMap<int, bool>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
+ for ( QMap<QtxActionMgrId, bool>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
{
- MenuNode* node = it.key() == -1 ? myRoot : find( it.key() );
+ MenuNode* node = it.key().isNull() ? myRoot : find( it.key() );
if ( node )
updateMenu( node, it.value() );
}
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
QWidget* menuWidget() const;
- virtual bool isVisible( const int, const int ) const;
- virtual void setVisible( const int, const int, const bool );
-
- int insert( const int, const QString&, const int, const int = -1 );
- int insert( QAction*, const QString&, const int, const int = -1 );
+ virtual bool isVisible( const QtxActionMgrId&, const QtxActionMgrId& ) const;
+ virtual void setVisible( const QtxActionMgrId&, const QtxActionMgrId&, const bool );
- int insert( const int, const QStringList&, const int, const int = -1 );
- int insert( QAction*, const QStringList&, const int, const int = -1 );
+ QtxActionMgrId insert( const QtxActionMgrId&, const QString&, const int, const int = -1 );
+ QtxActionMgrId insert( QAction*, const QString&, const int, const int = -1 );
- virtual int insert( const int, const int, const int, const int = -1 );
- int insert( QAction*, const int, const int, const int = -1 );
+ QtxActionMgrId insert( const QtxActionMgrId&, const QStringList&, const int, const int = -1 );
+ QtxActionMgrId insert( QAction*, const QStringList&, const int, const int = -1 );
- int insert( const QString&, const QString&, const int, const int = -1, const int = -1 );
- int insert( const QString&, const QStringList&, const int, const int = -1, const int = -1 );
- virtual int insert( const QString&, const int, const int, const int = -1, const int = -1 );
+ virtual QtxActionMgrId insert( const QtxActionMgrId&, const QtxActionMgrId&, const int, const int = -1 );
+ QtxActionMgrId insert( QAction*, const QtxActionMgrId&, const int, const int = -1 );
- int append( const int, const int, const int );
- int append( QAction*, const int, const int );
- int append( const QString&, const int, const int, const int = -1 );
+ QtxActionMgrId insert( const QString&, const QString&, const int, const QtxActionMgrId& = QtxActionMgrId(), const int = -1 );
+ QtxActionMgrId insert( const QString&, const QStringList&, const int, const QtxActionMgrId& = QtxActionMgrId(), const int = -1 );
+ virtual QtxActionMgrId insert( const QString&, const QtxActionMgrId&, const int, const QtxActionMgrId& = QtxActionMgrId(), const int = -1 );
- int prepend( const int, const int, const int );
- int prepend( QAction*, const int, const int );
- int prepend( const QString&, const int, const int, const int = -1 );
+ void remove( const QtxActionMgrId& );
+ void remove( const QtxActionMgrId&, const QtxActionMgrId&, const int = -1 );
- void remove( const int );
- void remove( const int, const int, const int = -1 );
+ bool isShown( const QtxActionMgrId& ) const;
+ void setShown( const QtxActionMgrId&, const bool );
- void show( const int );
- void hide( const int );
-
- bool isShown( const int ) const;
- void setShown( const int, const bool );
-
- virtual void change( const int, const QString& );
+ virtual void change( const QtxActionMgrId&, const QString& );
virtual bool load( const QString&, QtxActionMgr::Reader& );
- bool containsMenu( const QString&, const int, const bool = false ) const;
- bool containsMenu( const int, const int, const bool = false ) const;
+ bool containsMenu( const QString&, const QtxActionMgrId&, const bool = false ) const;
+ bool containsMenu( const QtxActionMgrId&, const QtxActionMgrId&, const bool = false ) const;
- QMenu* findMenu( const int ) const;
- QMenu* findMenu( const QString&, const int, const bool = false ) const;
+ QMenu* findMenu( const QtxActionMgrId& ) const;
+ QMenu* findMenu( const QString&, const QtxActionMgrId&, const bool = false ) const;
- bool isEmptyEnabled( const int ) const;
- void setEmptyEnabled( const int, const bool );
+ bool isEmptyEnabled( const QtxActionMgrId& ) const;
+ void setEmptyEnabled( const QtxActionMgrId&, const bool );
bool menuCollapsible() const;
void setMenuCollapsible( bool );
- int menuPriority( const int ) const;
- void setMenuPriority( const int, const int );
+ int menuPriority( const QtxActionMgrId& ) const;
+ void setMenuPriority( const QtxActionMgrId&, const int );
- bool isPermanentMenu( const int ) const;
- void setPermanentMenu( const int, bool );
+ bool isPermanentMenu( const QtxActionMgrId& ) const;
+ void setPermanentMenu( const QtxActionMgrId&, bool );
private slots:
void onAboutToShow();
protected:
void setMenuWidget( QWidget* );
- MenuNode* find( const int, const int, const bool = true ) const;
- MenuNode* find( const int, MenuNode* = 0, const bool = true ) const;
- bool find( const int, NodeList&, MenuNode* = 0 ) const;
- MenuNode* find( const QString&, const int, const bool = true ) const;
+ MenuNode* find( const QtxActionMgrId&, const QtxActionMgrId&, const bool = true ) const;
+ MenuNode* find( const QtxActionMgrId&, MenuNode* = 0, const bool = true ) const;
+ bool find( const QtxActionMgrId&, NodeList&, MenuNode* = 0 ) const;
+ MenuNode* find( const QString&, const QtxActionMgrId&, const bool = true ) const;
MenuNode* find( const QString&, MenuNode* = 0, const bool = true ) const;
bool find( const QString&, NodeList&, MenuNode* = 0 ) const;
- int findId( const int, const int = -1 ) const;
+ QtxActionMgrId findId( const QtxActionMgrId&, const QtxActionMgrId& = QtxActionMgrId() ) const;
- void removeMenu( const int, MenuNode* );
+ void removeMenu( const QtxActionMgrId&, MenuNode* );
- QAction* itemAction( const int ) const;
- QAction* menuAction( const int ) const;
- int menuActionId( QAction* ) const;
+ QAction* itemAction( const QtxActionMgrId& ) const;
+ QAction* menuAction( const QtxActionMgrId& ) const;
+ QtxActionMgrId menuActionId( QAction* ) const;
void updateMenu( MenuNode* = 0, const bool = true, const bool = true );
virtual void internalUpdate();
QWidget* menuWidget( MenuNode* ) const;
void simplifySeparators( QWidget* );
QString clearTitle( const QString& ) const;
- int createMenu( const QStringList&, const int );
+ QtxActionMgrId createMenu( const QStringList&, const QtxActionMgrId& );
- void triggerUpdate( const int, const bool rec = true );
+ void triggerUpdate( const QtxActionMgrId&, const bool rec = true );
private:
typedef QMap<int, QAction*> MenuMap; //!< actions map
-
+
private:
- MenuNode* myRoot; //!< root menu node
- QWidget* myMenu; //!< menu widget
- MenuMap myMenus; //!< actions map
- bool myCollapse;
- QMap<int, bool> myUpdateIds; //!< list of actions ID being updated
+ MenuNode* myRoot; //!< root menu node
+ QWidget* myMenu; //!< menu widget
+ MenuMap myMenus; //!< actions map
+ bool myCollapse;
+ QMap<QtxActionMgrId, bool> myUpdateIds; //!< list of actions ID being updated
};
class QtxActionMenuMgr::MenuCreator : public QtxActionMgr::Creator
// File: QtxActionMgr.cxx
// Author: Alexander SOLOVYOV, Sergey TELKOV
-#include "Qtx.h"
#include "QtxActionMgr.h"
+
#include "QtxAction.h"
-#include <QFile>
-#include <QTimer>
+
+#include <QtCore/QFile>
+#include <QtCore/QTimer>
+
#ifndef QT_NO_DOM
-#include <QDomDocument>
-#include <QDomNode>
-#include <QCoreApplication>
+#include <QtXml/QDomNode>
+#include <QtXml/QDomDocument>
+#include <QtCore/QCoreApplication>
#endif
typedef QList< QPointer<QAction> > qtx_actionlist;
/*!
\class QtxActionMgr
\brief Manages a set of actions accessible by unique identifier.
-
+
Base class for menu, toolbar actions containers and popup menu creators.
Actions are registered in the manager with the registerAction() method
and unregistered from it with the unRegisterAction() method.
Functions action() and actionId() allow getting action by its identifier
- and vice versa. Method contains() returns \c true if the action with
+ and vice versa. Method contains() returns \c true if the action with
the specified identifier is already registered.
To get total number of the registered actions can be retrieved by
The method separator() allows creating a separator action which can be
used in the menus or toolbars to separate logical groups of actions.
-
+
To enable/disable any action by its identifier, use setEnabled() method.
*/
QtxActionMgr::QtxActionMgr( QObject* parent )
: QObject( parent ),
myUpdate( true ),
- myUpdTimer( 0 )
+ myUpdTimer( 0 ),
+ myIOHandler( 0 )
{
}
*/
QtxActionMgr::~QtxActionMgr()
{
+ delete myIOHandler;
}
/*!
\brief Register an action in the internal map.
- If \a userId is less than 0, the identifier for the action
- is generated automatically. If action with given \a userId
+ If \a userId is less than 0, the identifier for the action
+ is generated automatically. If action with given \a userId
is already registered, it will be re-registered.
\param a action to be registered
\return action ID (the same as userId or generated one)
\sa unRegisterAction()
*/
-int QtxActionMgr::registerAction( QAction* a, const int userId )
+QtxActionMgrId QtxActionMgr::registerAction( QAction* a, const QtxActionMgrId& userId )
{
if ( !a )
- return -1;
+ return QtxActionMgrId();
- int theId = userId < 0 ? generateId() : userId;
+ QtxActionMgrId theId = userId;
+ if ( theId.isNull() )
+ theId = QtxActionMgrId( generateId().id(), userId.context() );
if ( contains( theId ) )
unRegisterAction( theId );
- int cur = actionId( a );
- if ( cur != -1 )
+ QtxActionMgrId cur = actionId( a );
+ if ( !cur.isNull() )
{
- if ( userId == -1 )
+ if ( userId.isNull() )
return cur;
else
unRegisterAction( cur );
\param id action ID
\sa registerAction()
*/
-void QtxActionMgr::unRegisterAction( const int id )
+void QtxActionMgr::unRegisterAction( const QtxActionMgrId& id )
{
- if( contains( id ) )
+ if ( contains( id ) )
myActions.remove( id );
}
\return action (or 0 if \a id is invalid)
\sa actionId()
*/
-QAction* QtxActionMgr::action( const int id ) const
+QAction* QtxActionMgr::action( const QtxActionMgrId& id ) const
{
if ( contains( id ) )
- return myActions[ id ];
+ return myActions[id];
else
return 0;
}
\return action ID (or -1 if action is not found)
\sa action()
*/
-int QtxActionMgr::actionId( const QAction* a ) const
+QtxActionMgrId QtxActionMgr::actionId( const QAction* a ) const
{
if ( !a )
- return -1;
+ return QtxActionMgrId();
- int theId = -1;
- for ( ActionMap::ConstIterator it = myActions.begin(); it != myActions.end() && theId == -1; ++it )
+ QtxActionMgrId theId;
+ for ( ActionMap::ConstIterator it = myActions.begin(); it != myActions.end() && theId.isNull(); ++it )
{
if ( it.value() == a )
theId = it.key();
\param id action ID
\return \c true if internal map contains action with such identifier
*/
-bool QtxActionMgr::contains( const int id ) const
+bool QtxActionMgr::contains( const QtxActionMgrId& id ) const
{
return myActions.contains( id );
}
\brief Get all registered actions identifiers.
\return list of actions identifiers
*/
-QIntList QtxActionMgr::idList() const
+QList<QtxActionMgrId> QtxActionMgr::idList() const
{
return myActions.keys();
}
\return \c true if an action is visible to the parent
\sa setVisible()
*/
-bool QtxActionMgr::isVisible( const int /*actId*/, const int /*place*/ ) const
+bool QtxActionMgr::isVisible( const QtxActionMgrId& /*actId*/,
+ const QtxActionMgrId& /*place*/ ) const
{
return true;
}
\param v new visibility state
\sa isVisible()
*/
-void QtxActionMgr::setVisible( const int /*actId*/, const int /*place*/, const bool /*v*/ )
+void QtxActionMgr::setVisible( const QtxActionMgrId& /*actId*/,
+ const QtxActionMgrId& /*place*/, const bool /*v*/ )
{
}
myUpdTimer->stop();
}
+QtxActionMgrIO* QtxActionMgr::ioHandler() const
+{
+ return myIOHandler;
+}
+
+void QtxActionMgr::setIOHandler( QtxActionMgrIO* io )
+{
+ if ( myIOHandler == io )
+ return;
+
+ delete myIOHandler;
+ myIOHandler = io;
+}
+
+bool QtxActionMgr::load( const QString& ref )
+{
+ if ( !ioHandler() || ref.isEmpty() )
+ return false;
+
+ QMap<QtxActionMgrId, QtxActionMgrIO::Node> nodeMap;
+ if ( !ioHandler()->load( ref, nodeMap ) )
+ return false;
+
+ return retrieve( nodeMap );
+}
+
+bool QtxActionMgr::save( const QString& ref )
+{
+ if ( !ioHandler() || ref.isEmpty() )
+ return false;
+
+ QMap<QtxActionMgrId, QtxActionMgrIO::Node> nodeMap;
+ if ( !store( nodeMap ) )
+ return false;
+
+ return ioHandler()->save( ref, nodeMap );
+}
+
/*!
\brief Internal update.
- This method is called by update() function and can be redefined
+ This method is called by update() function and can be redefined
in subclasses to customize update operation. Base implementation
does nothing.
*/
\brief Generate unique action identifier.
\return new ID
*/
-int QtxActionMgr::generateId() const
+QtxActionMgrId QtxActionMgr::generateId() const
{
static int id = -1;
return --id;
\param id action ID
\return \c true if action is enabled
*/
-bool QtxActionMgr::isEnabled( const int id ) const
+bool QtxActionMgr::isEnabled( const QtxActionMgrId& id ) const
{
QAction* a = action( id );
if ( a )
\param id action ID
\param enable new state
*/
-void QtxActionMgr::setEnabled( const int id, const bool enable )
+void QtxActionMgr::setEnabled( const QtxActionMgrId& id, const bool enable )
{
QAction* a = action( id );
if ( a )
{
}
+bool QtxActionMgr::retrieve( const QMap<QtxActionMgrId, QtxActionMgrIO::Node>& )
+{
+ return true;
+}
+
+bool QtxActionMgr::store( QMap<QtxActionMgrId, QtxActionMgrIO::Node>& /*nodeMap*/ ) const
+{
+ /*
+ for ( ActionMap::const_iterator it = myActions.begin(); it != myActions.end(); ++it ) {
+ QtxActionMgrIO::Node node( it.key() );
+ nodeMap.insert( it.key(), node );
+ }
+ */
+ return true;
+}
+
+QtxActionMgrId QtxActionMgr::findSeparator() const
+{
+ QtxActionMgrId id;
+ for ( ActionMap::const_iterator it = myActions.begin(); it != myActions.end() && id.isNull(); ++it ) {
+ if ( it.value()->isSeparator() )
+ id = it.key();
+ }
+ return id;
+}
+
/*!
\brief Called when delayed update is performed (via timer event).
\class QtxActionMgr::Reader
\brief Generic actions description files reader class.
- This class is used to read files of some format to create actions
+ This class is used to read files of some format to create actions
and fill an action manager with the actions automatically.
*/
/*!
\brief Get option value.
-
+
If there is no such option the default value (\a def) is returned.
\param name option name
/*!
\fn bool QtxActionMgr::Reader::read( const QString& fname, Creator& cr ) const
- \brief Read the file and fill and action manager with actions
- by using help actions creator.
+ \brief Read the file and fill and action manager with actions
+ by using help actions creator.
This method should be redefined in the subclasses.
-
+
\param fname XML file name
\param cr actions creator
\return \c true on success and \c false in case of error
\class QtxActionMgr::XMLReader
\brief XML file reader.
- This class is used to read files of XML format to create
+ This class is used to read files of XML format to create
actions and fill an action manager with actions automatically.
*/
}
/*!
- \brief Read the file and fill and action manager with actions
+ \brief Read the file and fill and action manager with actions
by using actions creator.
\param fname XML file name
\param cr actions creator
\class QtxActionMgr::Creator
\brief Generic actions creator class.
- Used by Reader to create actions and fill in the action
+ Used by Reader to create actions and fill in the action
manager with the actions.
*/
/*!
\brief Connect action to some specific slot(s).
- This method can be redefined in subclasses.
+ This method can be redefined in subclasses.
Base implementation does nothing.
\param a action
}
/*!
- \fn int QtxActionMgr::Creator::append( const QString& tag,
- const bool subMenu,
+ \fn int QtxActionMgr::Creator::append( const QString& tag,
+ const bool subMenu,
const ItemAttributes& attr,
const int pId )
\brief Create (and probably append to the action manager) new action.
This method should be redefined in the subclasses.
-
+
\param tag item tag name
\param subMenu \c true if this item is submenu
\param attr attributes map
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#include "Qtx.h"
+#include "QtxActionMgrId.h"
+#include "QtxActionMgrIO.h"
+
#include <QMap>
#include <QObject>
#include <QPointer>
#pragma warning( disable:4251 )
#endif
-
class QTX_EXPORT QtxActionMgr : public QObject
{
- Q_OBJECT
+ Q_OBJECT
class SeparatorAction;
QtxActionMgr( QObject* parent );
virtual ~QtxActionMgr();
- virtual int registerAction( QAction*, const int = -1 );
- virtual void unRegisterAction( const int );
+ virtual QtxActionMgrId registerAction( QAction*, const QtxActionMgrId& = QtxActionMgrId() );
+ virtual void unRegisterAction( const QtxActionMgrId& );
- QAction* action( const int ) const;
- int actionId( const QAction* ) const;
- bool contains( const int ) const;
+ QAction* action( const QtxActionMgrId& ) const;
+ QtxActionMgrId actionId( const QAction* ) const;
+ bool contains( const QtxActionMgrId& ) const;
int count() const;
bool isEmpty() const;
- QIntList idList() const;
+
+ QList<QtxActionMgrId> idList() const;
bool isUpdatesEnabled() const;
virtual void setUpdatesEnabled( const bool );
- virtual bool isVisible( const int, const int ) const;
- virtual void setVisible( const int, const int, const bool );
+ virtual bool isVisible( const QtxActionMgrId&, const QtxActionMgrId& ) const;
+ virtual void setVisible( const QtxActionMgrId&, const QtxActionMgrId&, const bool );
void update();
- virtual bool isEnabled( const int ) const;
- virtual void setEnabled( const int, const bool );
+ virtual bool isEnabled( const QtxActionMgrId& ) const;
+ virtual void setEnabled( const QtxActionMgrId&, const bool );
+
+ QtxActionMgrIO* ioHandler() const;
+ void setIOHandler( QtxActionMgrIO* );
+
+ bool load( const QString& );
+ bool save( const QString& );
static QAction* separator( const bool = false );
protected:
virtual void internalUpdate();
- int generateId() const;
+ QtxActionMgrId generateId() const;
void triggerUpdate();
virtual void updateContent();
+ virtual bool retrieve( const QMap<QtxActionMgrId, QtxActionMgrIO::Node>& );
+ virtual bool store( QMap<QtxActionMgrId, QtxActionMgrIO::Node>& ) const;
+
+ QtxActionMgrId findSeparator() const;
+
private slots:
void onUpdateContent();
private:
- typedef QPointer<QAction> ActionPtr; //!< Action guarded pointer
- typedef QMap<int, ActionPtr> ActionMap; //!< Actions map
+ typedef QPointer<QAction> ActionPtr; //!< Action guarded pointer
+ typedef QMap<QtxActionMgrId, ActionPtr> ActionMap; //!< Actions map
private:
bool myUpdate; //!< update flag
ActionMap myActions; //!< actions map
QTimer* myUpdTimer; //!< update timer
+ QtxActionMgrIO* myIOHandler;
};
-
QTX_EXPORT typedef QMap<QString, QString> ItemAttributes; //!< attributes map
class QTX_EXPORT QtxActionMgr::Creator
virtual bool isNodeSimilar( const QDomNode&, const QString& ) const;
};
-
#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionMgrIO.cxx
+// Author: Sergey TELKOV
+
+#include "QtxActionMgrIO.h"
+
+#include "QtxResourceMgr.h"
+
+QtxActionMgrIO::QtxActionMgrIO()
+{
+}
+
+QtxActionMgrIO::~QtxActionMgrIO()
+{
+}
+
+/*!
+ \brief Get the list of options.
+ \return options list
+*/
+QStringList QtxActionMgrIO::options() const
+{
+ return myOptions.keys();
+}
+
+/*!
+ \brief Get option value.
+
+ If there is no such option the default value (\a def) is returned.
+
+ \param name option name
+ \param def default option value
+ \return option value
+*/
+QString QtxActionMgrIO::option( const QString& name, const QString& def ) const
+{
+ return myOptions.contains( name ) ? myOptions[name] : def;
+}
+
+/*!
+ \brief Set option value.
+ \param name option name
+ \param value new option value
+*/
+void QtxActionMgrIO::setOption( const QString& name, const QString& value )
+{
+ myOptions.insert( name, value );
+}
+
+
+
+QtxActionMgrResIO::QtxActionMgrResIO( QtxResourceMgr* resMgr )
+ : QtxActionMgrIO(),
+ myResMgr( resMgr )
+{
+}
+
+QtxActionMgrResIO::~QtxActionMgrResIO()
+{
+}
+
+QtxResourceMgr* QtxActionMgrResIO::resourceMgr() const
+{
+ return myResMgr;
+}
+
+bool QtxActionMgrResIO::load( const QString& ref, QMap<QtxActionMgrId, Node>& nodeMap ) const
+{
+ QtxResourceMgr* resMgr = resourceMgr();
+ if ( !resMgr || ref.isEmpty() )
+ return false;
+
+ QStringList paramList = resMgr->parameters( ref );
+ for ( QStringList::iterator it = paramList.begin(); it != paramList.end(); ++it ) {
+ QString data;
+ QString param = *it;
+ QString value = resMgr->stringValue( ref, param );
+
+ int idx = param.indexOf( "." );
+ if ( idx != -1 ) {
+ data = param.mid( idx + 1 );
+ param = param.mid( 0, idx );
+ }
+ QtxActionMgrId id = nodeId( param );
+ if ( id.isNull() )
+ continue;
+
+ if ( !nodeMap.contains( id ) )
+ nodeMap.insert( id, Node( id ) );
+
+ Node& ioNode = nodeMap[id];
+ if ( data.isEmpty() ) {
+ QList<QtxActionMgrId> childList;
+ QStringList lst = value.split( "," );
+ for ( QStringList::iterator it = lst.begin(); it != lst.end(); ++it ) {
+ QtxActionMgrId childId = nodeId( *it );
+ if ( !childId.isNull() )
+ childList.append( childId );
+ }
+ ioNode.setChildren( childList );
+ }
+ else
+ ioNode.setData( data, value );
+ }
+
+ return true;
+}
+
+bool QtxActionMgrResIO::save( const QString& ref, const QMap<QtxActionMgrId, Node>& nodeMap ) const
+{
+ QtxResourceMgr* resMgr = resourceMgr();
+ if ( !resMgr || ref.isEmpty() )
+ return false;
+
+ resMgr->remove( ref );
+
+ for ( QMap<QtxActionMgrId, Node>::const_iterator it = nodeMap.begin(); it != nodeMap.end(); ++it ) {
+ const Node& ioNode = *it;
+ QString idName = nodeId( ioNode.id() );
+
+ QList<QtxActionMgrId> childList = ioNode.children();
+ if ( !childList.isEmpty() ) {
+ QStringList childStrList;
+ for ( QList<QtxActionMgrId>::iterator iter = childList.begin(); iter != childList.end(); ++iter )
+ childStrList.append( nodeId( *iter ) );
+ resMgr->setValue( ref, idName, childStrList.join( "," ) );
+ }
+
+ QStringList data = ioNode.data();
+ for ( QStringList::iterator itr = data.begin(); itr != data.end(); ++itr ) {
+ QString param = *itr;
+ if ( param.isEmpty() )
+ continue;
+
+ resMgr->setValue( ref, QString( "%1.%2" ).arg( idName ).arg( param ), ioNode.data( param ).toString() );
+ }
+ }
+
+ return true;
+}
+
+QtxActionMgrId QtxActionMgrResIO::nodeId( const QString& str ) const
+{
+ int id = -1;
+ QString ctx;
+ QString txt = str.trimmed();
+ if ( !txt.isEmpty() ) {
+ int idx = txt.indexOf( ":" );
+ if ( idx != -1 ) {
+ ctx = txt.mid( idx + 1 );
+ txt = txt.mid( 0, idx );
+ }
+ bool ok = false;
+ id = txt.toInt( &ok );
+ if ( !ok )
+ id = -1;
+ }
+
+ return QtxActionMgrId( id, id == -1 ? QString() : ctx );
+}
+
+QString QtxActionMgrResIO::nodeId( const QtxActionMgrId& id ) const
+{
+ QString res;
+ if ( !id.isNull() ) {
+ res = QString::number( id.id() );
+ if ( !id.context().isEmpty() )
+ res += QString( ":") + id.context();
+ }
+ return res;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionMgrIO.h
+// Author: Sergey TELKOV
+
+#ifndef QTXACTIONMGRIO_H
+#define QTXACTIONMGRIO_H
+
+#include "QtxActionMgrId.h"
+
+#include <QtCore/QMap>
+#include <QtCore/QVariant>
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class QtxResourceMgr;
+
+class QTX_EXPORT QtxActionMgrIO
+{
+public:
+ class Node
+ {
+ public:
+ Node() {}
+ Node( const QtxActionMgrId& id ) : myId( id ) {}
+ Node( const Node& node ) : myId( node.myId ), myData( node.myData ), myChildren( node.myChildren ) {}
+ ~Node() {}
+
+ QtxActionMgrId id() const { return myId; }
+ QList<QtxActionMgrId> children() const { return myChildren; }
+ void setChildren( const QList<QtxActionMgrId>& lst ) { myChildren = lst; }
+
+ QStringList data() const { return myData.keys(); }
+ QVariant data( const QString& name ) const { return myData.contains( name ) ? myData[name] : QVariant(); }
+ void setData( const QString& name, const QVariant& val ) { myData.insert( name, val ); }
+
+ private:
+ QtxActionMgrId myId;
+ QMap<QString, QVariant> myData;
+ QList<QtxActionMgrId> myChildren;
+ };
+
+public:
+ QtxActionMgrIO();
+ virtual ~QtxActionMgrIO();
+
+ QStringList options() const;
+ QString option( const QString&, const QString& = QString() ) const;
+ void setOption( const QString&, const QString& );
+
+ virtual bool load( const QString&, QMap<QtxActionMgrId, Node>& ) const = 0;
+ virtual bool save( const QString&, const QMap<QtxActionMgrId, Node>& ) const = 0;
+
+private:
+ QMap<QString, QString> myOptions;
+};
+
+class QTX_EXPORT QtxActionMgrResIO : public QtxActionMgrIO
+{
+public:
+ QtxActionMgrResIO( QtxResourceMgr* );
+ virtual ~QtxActionMgrResIO();
+
+ QtxResourceMgr* resourceMgr() const;
+
+ virtual bool load( const QString&, QMap<QtxActionMgrId, Node>& ) const;
+ virtual bool save( const QString&, const QMap<QtxActionMgrId, Node>& ) const;
+
+private:
+ QtxActionMgrId nodeId( const QString& ) const;
+ QString nodeId( const QtxActionMgrId& ) const;
+
+private:
+ QtxResourceMgr* myResMgr;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionMgrId.cxx
+// Author: Sergey TELKOV
+
+#include "QtxActionMgrId.h"
+
+QtxActionMgrId::QtxActionMgrId()
+ : myId( -1 )
+{
+}
+
+QtxActionMgrId::QtxActionMgrId( const int id )
+ : myId( id )
+{
+}
+
+QtxActionMgrId::QtxActionMgrId( const int id, const QString& ctx )
+ : myId( id ),
+ myCtx( ctx )
+{
+}
+
+QtxActionMgrId::QtxActionMgrId( const QtxActionMgrId& other )
+ : myId( other.myId ),
+ myCtx( other.myCtx )
+{
+}
+
+bool QtxActionMgrId::isNull() const
+{
+ return myId == -1;
+}
+
+int QtxActionMgrId::id() const
+{
+ return myId;
+}
+
+QString QtxActionMgrId::context() const
+{
+ return myCtx;
+}
+
+bool QtxActionMgrId::operator==( const QtxActionMgrId& other ) const
+{
+ return other.myId == myId && other.myCtx == myCtx;
+}
+
+bool QtxActionMgrId::operator!=( const QtxActionMgrId& other ) const
+{
+ return !( *this == other );
+}
+
+bool QtxActionMgrId::operator<( const QtxActionMgrId& other ) const
+{
+ if ( myId < other.myId )
+ return true;
+ else if ( myId == other.myId )
+ return myCtx < other.myCtx;
+ else
+ return false;
+}
+
+QtxActionMgrId::operator int() const
+{
+ return myId;
+}
+
+QtxActionMgrId::operator QString() const
+{
+ return myCtx;
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxActionMgrId.h
+// Author: Sergey TELKOV
+
+#ifndef QTXACTIONMGRID_H
+#define QTXACTIONMGRID_H
+
+#include "Qtx.h"
+
+#include <QMap>
+#include <QObject>
+#include <QPointer>
+
+class QTimer;
+class QAction;
+class QDomNode;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class QTX_EXPORT QtxActionMgrId
+{
+ public:
+ QtxActionMgrId();
+ QtxActionMgrId( const int );
+ QtxActionMgrId( const int, const QString& );
+ QtxActionMgrId( const QtxActionMgrId& );
+
+ bool isNull() const;
+
+ int id() const;
+ QString context() const;
+
+ bool operator==( const QtxActionMgrId& ) const;
+ bool operator!=( const QtxActionMgrId& ) const;
+ bool operator<( const QtxActionMgrId& ) const;
+
+ operator int() const;
+ operator QString() const;
+
+ private:
+ int myId;
+ QString myCtx;
+};
+
+#endif
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
/*!
\class QtxActionToolMgr
\brief Toolbar actions manager.
-
+
Toolbar manager allows using of set of action for automatic generating of
application toolbars and dynamic update of toolbars contents.
\param mw parent main window; if it is null, the tool manager's main window is used
\return id of created/found toolbar
*/
-int QtxActionToolMgr::createToolBar( const QString& title, const int tid, QMainWindow* mw )
+QtxActionMgrId QtxActionToolMgr::createToolBar( const QString& title, const QtxActionMgrId& tid, QMainWindow* mw )
{
static int _toolBarId = -1;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && tbId == -1; ++it )
{
if( it.value().toolBar->windowTitle().toLower() == title.toLower() &&
- ( !mw || it.value().toolBar->parent()==mw ) )
+ ( !mw || it.value().toolBar->parent() == mw ) )
tbId = it.key();
}
QMainWindow* tbw = mw ? mw : mainWindow();
QToolBar* tb = find( title, tbw );
- tbId = tid < 0 ? --_toolBarId : tid;
+ tbId = tid.isNull() ? --_toolBarId : tid.id();
myToolBars.insert( tbId, ToolBarInfo() );
ToolBarInfo& tInfo = myToolBars[tbId];
}
/*!
- \brief Search toolbar with given \a title owned by main window \mw.
+ \brief Search toolbar with given \a title owned by main window \mw.
\param title toolbar title
\param mw main window
\return toolbar or 0 if it is not found
\brief Remove toolbar.
\param tid toolbar ID
*/
-void QtxActionToolMgr::removeToolBar( const int tid )
+void QtxActionToolMgr::removeToolBar( const QtxActionMgrId& tid )
{
if ( !myToolBars.contains( tid ) )
return;
\param idx action index in the toolbar (if < 0, action is appended to the end)
\return action ID
*/
-int QtxActionToolMgr::insert( const int id, const int tid, const int idx )
+QtxActionMgrId QtxActionToolMgr::insert( const QtxActionMgrId& id, const QtxActionMgrId& tid, const int idx )
{
if ( !contains( id ) || !hasToolBar( tid ) )
- return -1;
+ return QtxActionMgrId();
/*
if ( containsAction( id, tid ) )
remove( id, tid );
\param idx action index in the toolbar (if < 0, action is appended to the end)
\return action ID
*/
-int QtxActionToolMgr::insert( QAction* a, const int tid, const int idx )
+QtxActionMgrId QtxActionToolMgr::insert( QAction* a, const QtxActionMgrId& tid, const int idx )
{
return insert( registerAction( a ), tid, idx );
}
\param idx action index in the toolbar (if < 0, action is appended to the end)
\return action ID
*/
-int QtxActionToolMgr::insert( const int id, const QString& title, const int idx )
+QtxActionMgrId QtxActionToolMgr::insert( const QtxActionMgrId& id, const QString& title, const int idx )
{
return insert( id, createToolBar( title ), idx );
}
\param idx action index in the toolbar (if < 0, action is appended to the end)
\return action ID
*/
-int QtxActionToolMgr::insert( QAction* a, const QString& title, const int idx )
+QtxActionMgrId QtxActionToolMgr::insert( QAction* a, const QString& title, const int idx )
{
return insert( registerAction( a ), createToolBar( title ), idx );
}
-/*!
- \brief Append action to the end of toolbar.
- \param id action ID
- \param tid toolbar ID
- \return action ID
-*/
-int QtxActionToolMgr::append( const int id, const int tid )
-{
- return insert( id, tid );
-}
-
-/*!
- \brief Append action to the end of toolbar.
- \param a action
- \param tid toolbar ID
- \return action ID
-*/
-int QtxActionToolMgr::append( QAction* a, const int tid )
-{
- return insert( a, tid );
-}
-
-/*!
- \brief Append action to the end of toolbar.
- \param id action ID
- \param title toolbar title
- \return action ID
-*/
-int QtxActionToolMgr::append( const int id, const QString& title )
-{
- return insert( id, title );
-}
-
-/*!
- \brief Append action to the end of toolbar.
- \param a action
- \param title toolbar title
- \return action ID
-*/
-int QtxActionToolMgr::append( QAction* a, const QString& title )
-{
- return insert( a, title );
-}
-
-/*!
- \brief Insert action to the beginning of toolbar.
- \param id action ID
- \param tid toolbar ID
- \return action ID
-*/
-int QtxActionToolMgr::prepend( const int id, const int tid )
-{
- return insert( id, tid, 0 );
-}
-
-/*!
- \brief Insert action to the beginning of toolbar.
- \param a action
- \param tid toolbar ID
- \return action ID
-*/
-int QtxActionToolMgr::prepend( QAction* a, const int tid )
-{
- return insert( a, tid, 0 );
-}
-
-/*!
- \brief Insert action to the beginning of toolbar.
- \param id action ID
- \param title toolbar title
- \return action ID
-*/
-int QtxActionToolMgr::prepend( const int id, const QString& title )
-{
- return insert( id, title, 0 );
-}
-
-/*!
- \brief Insert action to the beginning of toolbar.
- \param a action ID
- \param title toolbar title
- \return action ID
-*/
-int QtxActionToolMgr::prepend( QAction* a, const QString& title )
-{
- return insert( a, title, 0 );
-}
-
/*!
\brief Remove action from toolbar.
\param id action ID
\param tid toolbar ID
*/
-void QtxActionToolMgr::remove( const int id, const int tid )
+void QtxActionToolMgr::remove( const QtxActionMgrId& id, const QtxActionMgrId& tid )
{
if ( !myToolBars.contains( tid ) )
return;
\param id action ID
\param title toolbar title
*/
-void QtxActionToolMgr::remove( const int id, const QString& title )
+void QtxActionToolMgr::remove( const QtxActionMgrId& id, const QString& title )
{
remove( id, find( title ) );
}
\param tid toolbar ID
\return toolbar or 0 if it is not found
*/
-QToolBar* QtxActionToolMgr::toolBar( const int tid ) const
+QToolBar* QtxActionToolMgr::toolBar( const QtxActionMgrId& tid ) const
{
QToolBar* tb = 0;
if ( myToolBars.contains( tid ) )
\param tid toolbar ID
\return \c true if toolbar is registered in the toolbar manager
*/
-bool QtxActionToolMgr::hasToolBar( const int tid ) const
+bool QtxActionToolMgr::hasToolBar( const QtxActionMgrId& tid ) const
{
return myToolBars.contains( tid );
}
*/
bool QtxActionToolMgr::hasToolBar( const QString& title ) const
{
- return find( title ) != -1;
+ return !find( title ).isNull();
}
/*!
\param tid toolbar ID
\return \c true if toolbar contains action
*/
-bool QtxActionToolMgr::containsAction( const int id, const int tid ) const
+bool QtxActionToolMgr::containsAction( const QtxActionMgrId& id, const QtxActionMgrId& tid ) const
{
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it )
{
- if ( tid == -1 || it.key() == tid )
+ if ( tid.isNull() || it.key() == tid )
{
const NodeList& list = it.value().nodes;
for ( NodeList::const_iterator nit = list.begin(); nit != list.end(); ++nit )
return false;
}
+QList<QtxActionMgrId> QtxActionToolMgr::toolBars() const
+{
+ QList<QtxActionMgrId> res;
+ for ( ToolBarMap::const_iterator it = myToolBars.begin(); it != myToolBars.end(); ++it ) {
+ res.append( it.key() );
+ }
+ return res;
+}
+
+QList<QtxActionMgrId> QtxActionToolMgr::toolBarActions( const QtxActionMgrId& tbId ) const
+{
+ QList<QtxActionMgrId> res;
+ if ( myToolBars.contains( tbId ) ) {
+ const NodeList& nodeList = myToolBars[tbId].nodes;
+ for ( NodeList::const_iterator it = nodeList.begin(); it != nodeList.end(); ++it )
+ res.append( (*it).id );
+ }
+ return res;
+}
+
/*!
\brief Called when toolbar is destroyed.
\param title toolbar title
\return toolbar ID or -1 if it is not found
*/
-int QtxActionToolMgr::find( const QString& title ) const
+QtxActionMgrId QtxActionToolMgr::find( const QString& title ) const
{
- int id = -1;
- for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id == -1; ++it )
+ QtxActionMgrId id;
+ for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id.isNull(); ++it )
{
if ( it.value().toolBar->windowTitle() == title )
id = it.key();
\param tb toolbar
\return toolbar ID or -1 if toolbar is not registered
*/
-int QtxActionToolMgr::find( QToolBar* tb ) const
+QtxActionMgrId QtxActionToolMgr::find( QToolBar* tb ) const
{
- int id = -1;
- for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id == -1; ++it )
+ QtxActionMgrId id;
+ for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id.isNull(); ++it )
{
if ( it.value().toolBar == tb )
id = it.key();
\brief Update toolbar.
\param tid toolbar ID
*/
-void QtxActionToolMgr::updateToolBar( const int tid )
+void QtxActionToolMgr::updateToolBar( const QtxActionMgrId& tid )
{
if ( !isUpdatesEnabled() )
return;
}
simplifySeparators( tb );
-
+
// fix of 19921 -->
if ( !tb->isVisible() )
tb->adjustSize();
Qtx::simplifySeparators( tb );
}
-/*!
- \brief Show action (in all toolbars).
- \param id action ID
-*/
-void QtxActionToolMgr::show( const int id )
-{
- setShown( id, true );
-}
-
-/*!
- \brief Hide action (in all toolbars).
- \param id action ID
-*/
-void QtxActionToolMgr::hide( const int id )
-{
- setShown( id, false );
-}
-
/*!
\brief Set visibility status for toolbar action with given \a id.
\param id action ID
\param on new visibility status
*/
-void QtxActionToolMgr::setShown( const int id, const bool on )
+void QtxActionToolMgr::setShown( const QtxActionMgrId& id, const bool on )
{
for ( ToolBarMap::Iterator it = myToolBars.begin(); it != myToolBars.end(); ++it )
setVisible( id, it.key(), on );
\param id action ID
\return \c true if action is shown in all toolbars
*/
-bool QtxActionToolMgr::isShown( const int id ) const
+bool QtxActionToolMgr::isShown( const QtxActionMgrId& id ) const
{
QList<const ToolNode*> nodes;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it )
\param tid toolbar ID
\return \c true if action is shown in the toolbar
*/
-bool QtxActionToolMgr::isVisible( const int id, const int tid ) const
+bool QtxActionToolMgr::isVisible( const QtxActionMgrId& id, const QtxActionMgrId& tid ) const
{
if ( !myToolBars.contains( tid ) )
return false;
{
const ToolNode& node = *it;
if ( node.id == id )
-
vis = node.visible;
}
return vis;
\param tid toolbar ID
\param on new visibility status
*/
-void QtxActionToolMgr::setVisible( const int id, const int tid, const bool on )
+void QtxActionToolMgr::setVisible( const QtxActionMgrId& id, const QtxActionMgrId& tid, const bool on )
{
if ( !myToolBars.contains( tid ) )
return;
\param r actions reader
\return \c true on success and \c false on error
*/
+/*
bool QtxActionToolMgr::load( const QString& fname, QtxActionMgr::Reader& r )
{
ToolCreator cr( &r, this );
return r.read( fname, cr );
}
+*/
/*!
\brief Called when delayed content update is performed.
if ( !isUpdatesEnabled() )
return;
- for ( QMap<int,int>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
+ for ( QMap<QtxActionMgrId, int>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
updateToolBar( it.key() );
myUpdateIds.clear();
}
+bool QtxActionToolMgr::retrieve( const QMap<QtxActionMgrId, QtxActionMgrIO::Node>& nodeMap )
+{
+ if ( !QtxActionMgr::retrieve( nodeMap ) )
+ return false;
+
+ QList<QtxActionMgrIO::Node> tbList;
+ for ( QMap<QtxActionMgrId, QtxActionMgrIO::Node>::const_iterator it = nodeMap.begin();
+ it != nodeMap.end(); ++it ) {
+ QtxActionMgrId id = it.key();
+ QtxActionMgrIO::Node ioNode = it.value();
+
+ if ( ioNode.data( "type" ) == QString( "toolbar" ) )
+ tbList.append( ioNode );
+ }
+
+ bool status = true;
+
+ for ( QList<QtxActionMgrIO::Node>::iterator itr = tbList.begin(); itr != tbList.end() && status; ++itr ) {
+ QtxActionMgrIO::Node ioNode = *itr;
+
+ QString title;
+ QVariant name = ioNode.data( "name" );
+ if ( name.isValid() )
+ title = name.toString();
+ if ( title.isEmpty() )
+ continue;
+
+ QtxActionMgrId tbId = createToolBar( title, ioNode.id() );
+
+ if ( tbId.isNull() || !myToolBars.contains( tbId ) )
+ status = false;
+ else {
+ ToolBarInfo& inf = myToolBars[tbId];
+ NodeList tbNodes;
+ QList<QtxActionMgrId> childList = ioNode.children();
+ for ( QList<QtxActionMgrId>::iterator iter = childList.begin(); iter != childList.end(); ++iter ) {
+ QtxActionMgrId tbNodeId = *iter;
+ if ( tbNodeId.isNull() )
+ continue;
+
+ if ( nodeMap.contains( tbNodeId ) && nodeMap[tbNodeId].data( "type" ).toString() == QString( "separator" ) ) {
+ QAction* sep = action( tbNodeId );
+ if ( !sep )
+ tbNodeId = registerAction( separator(), tbNodeId );
+ }
+
+ ToolNode toolNode( tbNodeId );
+
+ if ( nodeMap.contains( tbNodeId ) && nodeMap[tbNodeId].data( "visible" ).canConvert( QVariant::Bool ) )
+ toolNode.visible = nodeMap[tbNodeId].data( "visible" ).toBool();
+ tbNodes.append( toolNode );
+ }
+ inf.nodes = tbNodes;
+ triggerUpdate( tbId );
+ }
+ }
+
+ return status;
+}
+
+bool QtxActionToolMgr::store( QMap<QtxActionMgrId, QtxActionMgrIO::Node>& nodeMap ) const
+{
+ if ( !QtxActionMgr::store( nodeMap ) )
+ return false;
+
+ for ( ToolBarMap::const_iterator it = myToolBars.begin(); it != myToolBars.end(); ++it ) {
+ int tbId = it.key();
+ const ToolBarInfo& inf = it.value();
+
+ QtxActionMgrIO::Node tbNode( tbId );
+ tbNode.setData( "type", "toolbar" );
+ tbNode.setData( "name", inf.toolBar->windowTitle() );
+
+ QList<QtxActionMgrId> childList;
+ for ( NodeList::const_iterator itr = inf.nodes.begin(); itr != inf.nodes.end(); ++itr ) {
+ const ToolNode& toolNode = *itr;
+ QtxActionMgrIO::Node ioNode( toolNode.id );
+ if ( nodeMap.contains( toolNode.id ) )
+ ioNode = nodeMap[toolNode.id];
+ ioNode.setData( "visible", toolNode.visible );
+ if ( action( toolNode.id ) && action( toolNode.id )->isSeparator() )
+ ioNode.setData( "type", "separator" );
+ childList.append( toolNode.id );
+ nodeMap.insert( toolNode.id, ioNode );
+ }
+ tbNode.setChildren( childList );
+ nodeMap.insert( tbId, tbNode );
+ }
+
+ return true;
+}
+
/*!
\brief Perform delayed toolbar update.
\param tid toolbar ID
*/
-void QtxActionToolMgr::triggerUpdate( const int tid )
+void QtxActionToolMgr::triggerUpdate( const QtxActionMgrId& tid )
{
myUpdateIds.insert( tid, 0 );
QtxActionMgr::triggerUpdate();
}
-
/*!
\class QtxActionToolMgr::ToolCreator
\brief Toolbars creator.
*/
int QtxActionToolMgr::ToolCreator::append( const QString& tag, const bool /*subMenu*/,
const ItemAttributes& attr, const int tid )
-{
+{
if( !myMgr || !reader() )
return -1;
QString toggleact = strValue( attr, toggle );
newAct->setCheckable( !toggleact.isEmpty() );
newAct->setChecked( toggleact.toLower() == "true" );
-
+
connect( newAct );
int aid = myMgr->registerAction( newAct, actId );
res = myMgr->insert( aid, tid, intValue( attr, pos, -1 ) );
#ifndef QTXACTIONTOOLMGR_H
#define QTXACTIONTOOLMGR_H
-#include "Qtx.h"
#include "QtxActionMgr.h"
#include <QMap>
class ToolNode
{
public:
- ToolNode() : id( -1 ), visible( true ) {};
- ToolNode( const int _id ) : id( _id ), visible( true ) {};
+ ToolNode() : visible( true ) {};
+ ToolNode( const QtxActionMgrId& _id ) : id( _id ), visible( true ) {};
- int id; //!< tool node ID
- bool visible; //!< visibility status
+ QtxActionMgrId id; //!< tool node ID
+ bool visible; //!< visibility status
};
typedef QList<ToolNode> NodeList; //!< toolbar nodes list
QMainWindow* mainWindow() const;
- int createToolBar( const QString&, int = -1, QMainWindow* = 0 );
+ QtxActionMgrId createToolBar( const QString&, const QtxActionMgrId& = QtxActionMgrId(), QMainWindow* = 0 );
void removeToolBar( const QString& );
- void removeToolBar( const int );
+ void removeToolBar( const QtxActionMgrId& );
- int insert( const int, const int, const int = -1 );
- int insert( QAction*, const int, const int = -1 );
- int insert( const int, const QString&, const int = -1 );
- int insert( QAction*, const QString&, const int = -1 );
+ QtxActionMgrId insert( const QtxActionMgrId&, const QtxActionMgrId&, const int = -1 );
+ QtxActionMgrId insert( QAction*, const QtxActionMgrId&, const int = -1 );
+ QtxActionMgrId insert( const QtxActionMgrId&, const QString&, const int = -1 );
+ QtxActionMgrId insert( QAction*, const QString&, const int = -1 );
- int append( const int, const int );
- int append( QAction*, const int );
- int append( const int, const QString& );
- int append( QAction*, const QString& );
+ virtual bool isVisible( const QtxActionMgrId&, const QtxActionMgrId& ) const;
+ virtual void setVisible( const QtxActionMgrId&, const QtxActionMgrId&, const bool );
- int prepend( const int, const int );
- int prepend( QAction*, const int );
- int prepend( const int, const QString& );
- int prepend( QAction*, const QString& );
+ bool isShown( const QtxActionMgrId& ) const;
+ void setShown( const QtxActionMgrId&, const bool );
- virtual bool isVisible( const int, const int ) const;
- virtual void setVisible( const int, const int, const bool );
+ void remove( const QtxActionMgrId&, const QtxActionMgrId& );
+ void remove( const QtxActionMgrId&, const QString& );
- void show( const int );
- void hide( const int );
- bool isShown( const int ) const;
- void setShown( const int, const bool );
-
- void remove( const int, const int );
- void remove( const int, const QString& );
-
- QToolBar* toolBar( const int ) const;
+ QToolBar* toolBar( const QtxActionMgrId& ) const;
QToolBar* toolBar( const QString& ) const;
- bool hasToolBar( const int ) const;
+ bool hasToolBar( const QtxActionMgrId& ) const;
bool hasToolBar( const QString& ) const;
- bool containsAction( const int, const int = -1 ) const;
+ bool containsAction( const QtxActionMgrId&, const QtxActionMgrId& = QtxActionMgrId() ) const;
- virtual bool load( const QString&, QtxActionMgr::Reader& );
+ QList<QtxActionMgrId> toolBars() const;
+ QList<QtxActionMgrId> toolBarActions( const QtxActionMgrId& ) const;
- int find( QToolBar* ) const;
+ // virtual bool load( const QString&, QtxActionMgr::Reader& );
+
+ QtxActionMgrId find( QToolBar* ) const;
protected slots:
void onToolBarDestroyed();
protected:
- int find( const QString& ) const;
+ QtxActionMgrId find( const QString& ) const;
QToolBar* find( const QString&, QMainWindow* ) const;
virtual void internalUpdate();
- void updateToolBar( const int );
+ void updateToolBar( const QtxActionMgrId& );
virtual void updateContent();
+ virtual bool retrieve( const QMap<QtxActionMgrId, QtxActionMgrIO::Node>& );
+ virtual bool store( QMap<QtxActionMgrId, QtxActionMgrIO::Node>& ) const;
+
private:
void simplifySeparators( QToolBar* );
- void triggerUpdate( const int );
+ void triggerUpdate( const QtxActionMgrId& );
private:
typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo; //!< toolbar info
typedef QMap<int, ToolBarInfo> ToolBarMap; //!< toolbars map
private:
- ToolBarMap myToolBars; //!< toobars map
- QMainWindow* myMainWindow; //!< parent main window
- QMap<int,int> myUpdateIds; //!< list of actions ID being updated
+ ToolBarMap myToolBars; //!< toobars map
+ QMainWindow* myMainWindow; //!< parent main window
+ QMap<QtxActionMgrId, int> myUpdateIds; //!< list of actions ID being updated
};
class QtxActionToolMgr::ToolCreator : public QtxActionMgr::Creator
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
virtual int append( const QString&, const bool,
const ItemAttributes&, const int );
- virtual QString rule( const ItemAttributes&,
+ virtual QString rule( const ItemAttributes&,
const QtxPopupMgr::RuleType = VisibleRule ) const;
private:
bool isToggle = !toggleact.isEmpty();
newAct->setCheckable( isToggle );
newAct->setChecked( toggleact.toLower() == "true" );
-
+
connect( newAct );
- int aid = mgr->registerAction( newAct, actId );
+ int aid = mgr->registerAction( newAct, actId );
QString arule = rule( attr, QtxPopupMgr::VisibleRule );
if ( !arule.isEmpty() )
myMgr->setRule( newAct, arule, QtxPopupMgr::VisibleRule );
\param ruleType rule type (QtxPopupMgr::RuleType)
\return rule for the menu item corresponding to the rule type
*/
-QString QtxPopupMgr::PopupCreator::rule( const ItemAttributes& /*attr*/,
+QString QtxPopupMgr::PopupCreator::rule( const ItemAttributes& /*attr*/,
const QtxPopupMgr::RuleType /*ruleType*/ ) const
{
return QString();
parameter found in the rule by the expression parser.
Use setSelection() and selection() to set/get the selection instance
for the popup menu manager.
-
- Popup menu manager automatically optimizes the menu by removing
+
+ Popup menu manager automatically optimizes the menu by removing
extra separators, hiding empty popup submenus etc.
*/
if ( mySelection )
mySelection->setParent( this );
- connect( mySelection, SIGNAL( destroyed( QObject* ) ),
+ connect( mySelection, SIGNAL( destroyed( QObject* ) ),
this, SLOT( onSelectionDestroyed( QObject* ) ) );
QtxActionMgr::triggerUpdate();
\param ruleType rule type (QtxPopupMgr::RuleType)
\return action ID (the same as \a id or generated one)
*/
-int QtxPopupMgr::registerAction( QAction* act, const int id, const QString& rule, const QtxPopupMgr::RuleType ruleType )
+ QtxActionMgrId QtxPopupMgr::registerAction( QAction* act, const QtxActionMgrId& id,
+ const QString& rule, const QtxPopupMgr::RuleType ruleType )
{
- int _id = QtxActionMenuMgr::registerAction( act, id );
+ QtxActionMgrId _id = QtxActionMenuMgr::registerAction( act, id );
setRule( act, rule, ruleType );
return _id;
}
\brief Unregister action from internal map.
\param id action ID
*/
-void QtxPopupMgr::unRegisterAction( const int id )
+void QtxPopupMgr::unRegisterAction( const QtxActionMgrId& id )
{
QAction* a = action( id );
if ( myRules.contains( a ) )
\param ruleType rule type (QtxPopupMgr::RuleType)
\return action ID
*/
-int QtxPopupMgr::insertAction( const int id, const int pId, const QString& rule, const RuleType ruleType )
+ QtxActionMgrId QtxPopupMgr::insertAction( const QtxActionMgrId& id, const QtxActionMgrId& pId,
+ const QString& rule, const RuleType ruleType )
{
- int res = QtxActionMenuMgr::insert( id, pId, -1 );
+ QtxActionMgrId res = QtxActionMenuMgr::insert( id, pId, -1 );
setRule( action( id ), rule, ruleType );
return res;
}
\param ruleType rule type (QtxPopupMgr::RuleType)
\return action ID
*/
-int QtxPopupMgr::insertAction( QAction* a, const int pId, const QString& rule, const RuleType ruleType )
+QtxActionMgrId QtxPopupMgr::insertAction( QAction* a, const QtxActionMgrId& pId,
+ const QString& rule, const RuleType ruleType )
{
- int res = QtxActionMenuMgr::insert( a, pId, -1 );
+ QtxActionMgrId res = QtxActionMenuMgr::insert( a, pId, -1 );
setRule( a, rule, ruleType );
return res;
}
\param id - action id
\param t - rule type
*/
-bool QtxPopupMgr::hasRule( const int id, const RuleType t ) const
+bool QtxPopupMgr::hasRule( const QtxActionMgrId& id, const RuleType t ) const
{
return hasRule( action( id ), t );
}
\param ruleType rule type (QtxPopupMgr::RuleType)
\return rule of required type
*/
-QString QtxPopupMgr::rule( const int id, const RuleType ruleType ) const
+QString QtxPopupMgr::rule( const QtxActionMgrId& id, const RuleType ruleType ) const
{
return rule( action( id ), ruleType );
}
\param ruleType rule type (QtxPopupMgr::RuleType)
\return rule of required type
*/
-void QtxPopupMgr::setRule( const int id, const QString& rule, const RuleType ruleType )
+void QtxPopupMgr::setRule( const QtxActionMgrId& id, const QString& rule, const RuleType ruleType )
{
setRule( action( id ), rule, ruleType );
}
The values of the parameters are given from the selection object
(QtxPopupSelection).
-
+
\param p expression parser
\param returning list of parameters names which are not retrieved from the selection
\sa selection()
\param place some parent action ID
\return \c true if the action is visible
*/
-bool QtxPopupMgr::isVisible( const int id, const int place ) const
+bool QtxPopupMgr::isVisible( const QtxActionMgrId& id, const QtxActionMgrId& place ) const
{
return QtxActionMenuMgr::isVisible( id, place ) && ( !hasRule( id ) || isSatisfied( action( id ) ) );
}
/*!
- \brief Perform internal update of the popup menu according
+ \brief Perform internal update of the popup menu according
to the current selection.
*/
void QtxPopupMgr::internalUpdate()
/*
\brief Get the specified parameter value.
\param name parameter name
- \param idx additional index used when used parameters with same names
+ \param idx additional index used when used parameters with same names
\return parameter value
\sa selection()
*/
else
{
if ( selection() )
- val = idx < 0 ? selection()->parameter( name ) :
+ val = idx < 0 ? selection()->parameter( name ) :
selection()->parameter( idx, name );
if ( val.isValid() )
{
/*!
\brief Called when selection is destroyed.
-
+
Prevents crashes when the selection object is destroyed outside the
popup manager.
/*!
\class QtxPopupSelection
- \brief This class is a part of the popup menu management system.
+ \brief This class is a part of the popup menu management system.
The QtxPopupSelection class is used as back-end for getting value
of each parameter found in the rule by the expression parser.
-
- For example, it can be used for the analyzing of the currently
+
+ For example, it can be used for the analyzing of the currently
selected objects and defining the values of the parameters used
in the rules syntax expression. Rules, in their turn, define
each action state - visibility, enabled and toggled state.
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
public:
//! Menu item rule type
- typedef enum {
+ typedef enum {
VisibleRule, //!< menu item visibility state
EnableRule, //!< menu item enable state
ToggleRule //!< menu item toggle state
QtxPopupMgr( QMenu*, QObject* = 0 );
virtual ~QtxPopupMgr();
- int insertAction( const int, const int, const QString&, const RuleType = VisibleRule );
- int insertAction( QAction*, const int, const QString&, const RuleType = VisibleRule );
+ QtxActionMgrId insertAction( const QtxActionMgrId&, const QtxActionMgrId&, const QString&, const RuleType = VisibleRule );
+ QtxActionMgrId insertAction( QAction*, const QtxActionMgrId&, const QString&, const RuleType = VisibleRule );
- virtual int registerAction( QAction*, const int, const QString& rule,
- const RuleType = VisibleRule );
- virtual void unRegisterAction( const int );
+ virtual QtxActionMgrId registerAction( QAction*, const QtxActionMgrId&, const QString& rule,
+ const RuleType = VisibleRule );
+ virtual void unRegisterAction( const QtxActionMgrId& );
- virtual bool isVisible( const int actId, const int place ) const;
+ virtual bool isVisible( const QtxActionMgrId& actId, const QtxActionMgrId& place ) const;
QString rule( QAction*, const RuleType = VisibleRule ) const;
- QString rule( const int, const RuleType = VisibleRule ) const;
+ QString rule( const QtxActionMgrId&, const RuleType = VisibleRule ) const;
void setRule( QAction*, const QString&, const RuleType = VisibleRule );
- void setRule( const int, const QString&, const RuleType = VisibleRule );
+ void setRule( const QtxActionMgrId&, const QString&, const RuleType = VisibleRule );
bool hasRule( QAction*, const RuleType = VisibleRule ) const;
- bool hasRule( const int, const RuleType = VisibleRule ) const;
+ bool hasRule( const QtxActionMgrId&, const RuleType = VisibleRule ) const;
QtxPopupSelection* selection() const;
void setSelection( QtxPopupSelection* );
// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#include <QSize>
#include <QtxAction.h>
+#include <QtxActionMgrId.h>
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
/*!
Destructor
*/
-SUIT_Application::~SUIT_Application()
+SUIT_Application::~SUIT_Application()
{
SUIT_Study* s = myStudy;
setActiveStudy( 0 );
}
/*!
- \return FALSE if application can not be closed (because of non saved data for example).
+ \return FALSE if application can not be closed (because of non saved data for example).
This method called by SUIT_Session whin closing of application was requested.
*/
bool SUIT_Application::isPossibleToClose( bool& )
}
/*!
- \return number of Studies.
+ \return number of Studies.
Must be redefined in Applications which support several studies for one Application instance.
*/
int SUIT_Application::getNbStudies() const
#define DEFAULT_MESSAGE_DELAY 3000
/*!
- Puts the message to the status bar
+ Puts the message to the status bar
\param msg - text of message
\param msec - time in milliseconds, after that the status label will be cleared
*/
return;
if ( myStudy )
- disconnect( myStudy, SIGNAL( studyModified( SUIT_Study* ) ),
+ disconnect( myStudy, SIGNAL( studyModified( SUIT_Study* ) ),
this, SLOT( updateCommandsStatus() ) );
if ( study )
- connect( study, SIGNAL( studyModified( SUIT_Study* ) ),
+ connect( study, SIGNAL( studyModified( SUIT_Study* ) ),
this, SLOT( updateCommandsStatus() ) );
-
+
myStudy = study;
}
{
if ( !a || !desktop() )
return;
-
+
QtxActionMenuMgr* mMgr = desktop()->menuMgr();
if ( mMgr )
mMgr->setShown( mMgr->actionId( a ), on );
{
if ( !a || !desktop() )
return;
-
+
QtxActionToolMgr* tMgr = desktop()->toolMgr();
if ( tMgr )
tMgr->setShown( tMgr->actionId( a ), on );
static int generatedId = -1;
ident = id == -1 ? --generatedId : id;
- if ( action( ident ) )
+ if ( action( ident ) )
qWarning( "Action registration id is already in use: %d", ident );
myActionMap.insert( ident, a );
if ( desktop() && desktop()->menuMgr() )
- desktop()->menuMgr()->registerAction( a );
+ desktop()->menuMgr()->registerAction( a, QtxActionMgrId( ident, applicationName() ) );
if ( desktop() && desktop()->toolMgr() )
- desktop()->toolMgr()->registerAction( a );
+ desktop()->toolMgr()->registerAction( a, QtxActionMgrId( ident, applicationName() ) );
return ident;
}
break;
}
- return QMainWindow::event( e );
+ return QtxMainWindow::event( e );
}
/*!
{
QtxActionToolMgr* mgr = toolMgr();
- mgr->append( DumpId, myToolBar );
- mgr->append( ViewTrihedronId, myToolBar );
+ mgr->insert( DumpId, myToolBar );
+ mgr->insert( ViewTrihedronId, myToolBar );
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
aScaleAction->insertAction( action( FitAllId ) );
aScaleAction->insertAction( action( FitRectId ) );
aScaleAction->insertAction( action( ZoomId ) );
- mgr->append( aScaleAction, myToolBar );
+ mgr->insert( aScaleAction, myToolBar );
QtxMultiAction* aPanningAction = new QtxMultiAction( this );
aPanningAction->insertAction( action( PanId ) );
aPanningAction->insertAction( action( GlobalPanId ) );
- mgr->append( aPanningAction, myToolBar );
+ mgr->insert( aPanningAction, myToolBar );
- mgr->append( ChangeRotationPointId, myToolBar );
+ mgr->insert( ChangeRotationPointId, myToolBar );
- mgr->append( RotationId, myToolBar );
+ mgr->insert( RotationId, myToolBar );
QtxMultiAction* aViewsAction = new QtxMultiAction( this );
aViewsAction->insertAction( action( FrontId ) );
aViewsAction->insertAction( action( BottomId ) );
aViewsAction->insertAction( action( LeftId ) );
aViewsAction->insertAction( action( RightId ) );
- mgr->append( aViewsAction, myToolBar );
+ mgr->insert( aViewsAction, myToolBar );
- mgr->append( ResetId, myToolBar );
+ mgr->insert( ResetId, myToolBar );
- mgr->append( UpdateRate, myToolBar );
- mgr->append( NonIsometric, myToolBar );
- mgr->append( GraduatedAxes, myToolBar );
- mgr->append( TextRegion, myToolBar );
- mgr->append( PrintId, myToolBar );
+ mgr->insert( UpdateRate, myToolBar );
+ mgr->insert( NonIsometric, myToolBar );
+ mgr->insert( GraduatedAxes, myToolBar );
+ mgr->insert( TextRegion, myToolBar );
+ mgr->insert( PrintId, myToolBar );
}
/*!