TOOL_ACTIONs are automagically registered by TOOL_MANAGER upon its construction.
This commit is contained in:
parent
f5325f8d79
commit
3fd26b6dd2
|
@ -44,8 +44,6 @@ ACTION_MANAGER::~ACTION_MANAGER()
|
|||
|
||||
void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
||||
{
|
||||
// Check if the TOOL_ACTION was not registered before
|
||||
assert( aAction->GetId() == -1 );
|
||||
// TOOL_ACTIONs are supposed to be named [appName.]toolName.actionName (with dots between)
|
||||
// action name without specifying at least toolName is not valid
|
||||
assert( aAction->GetName().find( '.', 0 ) != std::string::npos );
|
||||
|
@ -54,15 +52,14 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction )
|
|||
assert( m_actionNameIndex.find( aAction->m_name ) == m_actionNameIndex.end() );
|
||||
assert( m_actionIdIndex.find( aAction->m_id ) == m_actionIdIndex.end() );
|
||||
|
||||
aAction->setId( MakeActionId( aAction->m_name ) );
|
||||
if( aAction->m_id == -1 )
|
||||
aAction->m_id = MakeActionId( aAction->m_name );
|
||||
|
||||
m_actionNameIndex[aAction->m_name] = aAction;
|
||||
m_actionIdIndex[aAction->m_id] = aAction;
|
||||
|
||||
if( aAction->HasHotKey() )
|
||||
m_actionHotKeys[aAction->m_currentHotKey].push_back( aAction );
|
||||
|
||||
aAction->setActionMgr( this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,10 +68,6 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
|
|||
m_actionNameIndex.erase( aAction->m_name );
|
||||
m_actionIdIndex.erase( aAction->m_id );
|
||||
|
||||
// Indicate that the ACTION_MANAGER no longer care about the object
|
||||
aAction->setActionMgr( NULL );
|
||||
aAction->setId( -1 );
|
||||
|
||||
if( aAction->HasHotKey() )
|
||||
{
|
||||
std::list<TOOL_ACTION*>& actions = m_actionHotKeys[aAction->m_currentHotKey];
|
||||
|
|
|
@ -99,6 +99,11 @@ TOOL_MANAGER::TOOL_MANAGER() :
|
|||
m_model( NULL ), m_view( NULL ), m_viewControls( NULL ), m_editFrame( NULL )
|
||||
{
|
||||
m_actionMgr = new ACTION_MANAGER( this );
|
||||
|
||||
// Register known actions
|
||||
std::list<TOOL_ACTION*>& actionList = GetActionList();
|
||||
BOOST_FOREACH( TOOL_ACTION* action, actionList )
|
||||
RegisterAction( action );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -189,18 +189,6 @@ public:
|
|||
private:
|
||||
friend class ACTION_MANAGER;
|
||||
|
||||
/// Assigns an unique identifier. It is given by an instance of ACTION_MANAGER.
|
||||
void setId( int aId )
|
||||
{
|
||||
m_id = aId;
|
||||
}
|
||||
|
||||
/// Assigns ACTION_MANAGER object that handles the TOOL_ACTION.
|
||||
void setActionMgr( ACTION_MANAGER* aManager )
|
||||
{
|
||||
m_actionMgr = aManager;
|
||||
}
|
||||
|
||||
/// Name of the action (convention is: app.[tool.]action.name)
|
||||
std::string m_name;
|
||||
|
||||
|
@ -225,9 +213,6 @@ private:
|
|||
/// Unique ID for fast matching. Assigned by ACTION_MANAGER.
|
||||
int m_id;
|
||||
|
||||
/// Action manager that handles this TOOL_ACTION.
|
||||
ACTION_MANAGER* m_actionMgr;
|
||||
|
||||
/// Origin of the action
|
||||
// const TOOL_BASE* m_origin;
|
||||
|
||||
|
|
|
@ -60,11 +60,6 @@ void PCB_EDIT_FRAME::setupTools()
|
|||
wxCommandEventHandler( PCB_EDIT_FRAME::onGenericCommand ), NULL, this );
|
||||
#endif
|
||||
|
||||
// Register actions
|
||||
std::list<TOOL_ACTION*>& actionList = m_toolManager->GetActionList();
|
||||
BOOST_FOREACH( TOOL_ACTION* action, actionList )
|
||||
m_toolManager->RegisterAction( action );
|
||||
|
||||
// Register tools
|
||||
m_toolManager->RegisterTool( new SELECTION_TOOL );
|
||||
m_toolManager->RegisterTool( new ROUTER_TOOL );
|
||||
|
|
Loading…
Reference in New Issue