Implement undo/redo for lock/unlock/toggle lock.
Fixes: lp:1840770 * https://bugs.launchpad.net/kicad/+bug/1840770
This commit is contained in:
parent
fb21077d3a
commit
b219fbc3d2
|
@ -786,39 +786,41 @@ int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
|
||||||
{
|
{
|
||||||
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
|
||||||
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
const PCBNEW_SELECTION& selection = selTool->GetSelection();
|
||||||
|
BOARD_COMMIT commit( m_frame );
|
||||||
|
|
||||||
if( selection.Empty() )
|
if( selection.Empty() )
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true );
|
||||||
|
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
|
|
||||||
for( auto i : selection )
|
for( EDA_ITEM* item : selection )
|
||||||
{
|
{
|
||||||
auto item = static_cast<BOARD_ITEM*>( i );
|
BOARD_ITEM* board_item = static_cast<BOARD_ITEM*>( item );
|
||||||
bool prevState = item->IsLocked();
|
bool prevState = board_item->IsLocked();
|
||||||
|
|
||||||
|
commit.Modify( board_item );
|
||||||
|
|
||||||
switch( aMode )
|
switch( aMode )
|
||||||
{
|
{
|
||||||
case ON:
|
case ON: board_item->SetLocked( true ); break;
|
||||||
item->SetLocked( true );
|
case OFF: board_item->SetLocked( false ); break;
|
||||||
break;
|
case TOGGLE: board_item->SetLocked( !prevState ); break;
|
||||||
|
|
||||||
case OFF:
|
|
||||||
item->SetLocked( false );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOGGLE:
|
|
||||||
item->SetLocked( !prevState );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we really modified an item
|
// Check if we really modified an item
|
||||||
if( !modified && prevState != item->IsLocked() )
|
if( !modified && prevState != board_item->IsLocked() )
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( modified )
|
if( modified )
|
||||||
{
|
{
|
||||||
|
switch( aMode )
|
||||||
|
{
|
||||||
|
case ON: commit.Push( _( "Lock" ) ); break;
|
||||||
|
case OFF: commit.Push( _( "Unlock" ) ); break;
|
||||||
|
case TOGGLE: commit.Push( _( "Toggle Locking" ) ); break;
|
||||||
|
}
|
||||||
|
|
||||||
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
m_toolMgr->PostEvent( EVENTS::SelectedItemsModified );
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue