From 1b0cc82c56cd9904a93eb746572ad3e93544349f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 17 Dec 2023 21:01:31 +0000 Subject: [PATCH] Move a couple of stragglers to BOARD_COMMIT. --- pcbnew/board_commit.cpp | 20 +++++++++++--------- pcbnew/pcb_base_frame.cpp | 1 - pcbnew/pcb_edit_frame.cpp | 1 - pcbnew/pcb_view.cpp | 2 -- pcbnew/tools/board_editor_control.cpp | 1 - pcbnew/tools/edit_tool.cpp | 14 ++++++++++---- pcbnew/tools/group_tool.cpp | 12 +----------- pcbnew/undo_redo.cpp | 4 ++-- 8 files changed, 24 insertions(+), 31 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index b5cf84a882..6c92322f5c 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -382,26 +382,28 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags ) } case CHT_UNGROUP: - if( !( aCommitFlags & SKIP_UNDO ) ) + if( PCB_GROUP* group = boardItem->GetParentGroup() ) { - ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::UNGROUP ); - - if( PCB_GROUP* group = boardItem->GetParentGroup() ) + if( !( aCommitFlags & SKIP_UNDO ) ) + { + ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::UNGROUP ); itemWrapper.SetLink( group->Clone() ); + undoList.PushItem( itemWrapper ); + } - undoList.PushItem( itemWrapper ); + group->RemoveItem( boardItem ); } - boardItem->SetParentGroup( nullptr ); - break; case CHT_GROUP: if( addedGroup ) + { addedGroup->AddItem( boardItem ); - if( !( aCommitFlags & SKIP_UNDO ) ) - undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::REGROUP ) ); + if( !( aCommitFlags & SKIP_UNDO ) ) + undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::REGROUP ) ); + } break; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index de47c2e72b..af67258470 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index c9bfab67cb..2f778e16ef 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/pcb_view.cpp b/pcbnew/pcb_view.cpp index 6259342529..c30d7b0cfd 100644 --- a/pcbnew/pcb_view.cpp +++ b/pcbnew/pcb_view.cpp @@ -30,8 +30,6 @@ using namespace std::placeholders; #include #include #include - -#include #include namespace KIGFX { diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 8604db469b..6eb3e38465 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 6f1dc83dad..b7ae8a5c4a 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -2110,10 +2110,7 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) FOOTPRINT* parentFP = board_item->GetParentFootprint(); if( PCB_GROUP* parentGroup = board_item->GetParentGroup() ) - { - commit.Modify( parentGroup ); - parentGroup->RemoveItem( board_item ); - } + commit.Stage( board_item, CHT_UNGROUP ); switch( item->Type() ) { @@ -2134,7 +2131,13 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) case PCB_DIM_CENTER_T: case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: + commit.Remove( board_item ); + break; + case PCB_GROUP_T: + for( BOARD_ITEM* member : static_cast( board_item )->GetItems() ) + commit.Stage( member, CHT_UNGROUP ); + commit.Remove( board_item ); break; @@ -2193,6 +2196,9 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut ) } else { + for( BOARD_ITEM* member : static_cast( board_item )->GetItems() ) + commit.Stage( member, CHT_UNGROUP ); + commit.Remove( board_item ); } diff --git a/pcbnew/tools/group_tool.cpp b/pcbnew/tools/group_tool.cpp index 1738acad25..862d039950 100644 --- a/pcbnew/tools/group_tool.cpp +++ b/pcbnew/tools/group_tool.cpp @@ -337,23 +337,13 @@ int GROUP_TOOL::RemoveFromGroup( const TOOL_EVENT& aEvent ) if( selection.Empty() ) m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor ); - std::map> groupMap; - for( EDA_ITEM* item : selection ) { BOARD_ITEM* boardItem = static_cast( item ); PCB_GROUP* group = boardItem->GetParentGroup(); if( group ) - groupMap[ group ].push_back( boardItem ); - } - - for( std::pair> pair : groupMap ) - { - commit.Modify( pair.first ); - - for( BOARD_ITEM* item : pair.second ) - pair.first->RemoveItem( item ); + commit.Stage( boardItem, CHT_UNGROUP ); } commit.Push( wxT( "Remove Group Items" ) ); diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index 3e424a553f..7b21f3f446 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -423,9 +423,9 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) { if( !aList->GetPickedItemLink( ii ) ) aList->SetPickedItemLink( group->Clone(), ii ); - } - boardItem->SetParentGroup( nullptr ); + group->RemoveItem( boardItem ); + } } break;