Allow deletion of non-Reference/non-Value module text items.

Fixes: lp:1781226
* https://bugs.launchpad.net/kicad/+bug/1781226
This commit is contained in:
Jeff Young 2018-09-16 00:30:10 +01:00
parent aacb3f9075
commit a40ab768fc
2 changed files with 40 additions and 36 deletions

View File

@ -150,54 +150,31 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_PAD_T:
case PCB_MODULE_EDGE_T:
case PCB_MODULE_TEXT_T:
{
// Do not allow footprint text removal when not editing a module
// This level can only handle module items when editing modules
if( !m_editModules )
break;
bool remove = true;
if( boardItem->Type() == PCB_MODULE_TEXT_T )
{
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( boardItem );
switch( text->GetType() )
{
case TEXTE_MODULE::TEXT_is_REFERENCE:
//DisplayError( frame, _( "Cannot delete component reference." ) );
remove = false;
break;
case TEXTE_MODULE::TEXT_is_VALUE:
//DisplayError( frame, _( "Cannot delete component value." ) );
remove = false;
break;
case TEXTE_MODULE::TEXT_is_DIVERS: // suppress warnings
break;
default:
wxASSERT( false );
break;
}
// don't allow deletion of Reference or Value
if( text->GetType() != TEXTE_MODULE::TEXT_is_DIVERS )
break;
}
if( remove )
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
view->Remove( boardItem );
if( !( changeFlags & CHT_DONE ) )
{
MODULE* module = static_cast<MODULE*>( boardItem->GetParent() );
wxASSERT( module && module->Type() == PCB_MODULE_T );
module->Delete( boardItem );
}
board->m_Status_Pcb = 0; // it is done in the legacy view (ratsnest perhaps?)
MODULE* module = static_cast<MODULE*>( boardItem->GetParent() );
wxASSERT( module && module->Type() == PCB_MODULE_T );
module->Delete( boardItem );
}
board->m_Status_Pcb = 0; // it is done in the legacy view (ratsnest perhaps?)
break;
}
// Board items
case PCB_LINE_T: // a segment not on copper layers

View File

@ -892,7 +892,34 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
for( auto item : selection )
m_commit->Remove( item );
{
if( m_editModules )
{
m_commit->Remove( item );
continue;
}
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
{
auto text = static_cast<TEXTE_MODULE*>( item );
auto parent = static_cast<MODULE*>( item->GetParent() );
if( text->GetType() == TEXTE_MODULE::TEXT_is_DIVERS )
{
m_commit->Modify( text );
getView()->Remove( text );
parent->Remove( text );
}
}
break;
default:
m_commit->Remove( item );
break;
}
}
m_commit->Push( _( "Delete" ) );