Handle undo of a Repeat Draw Item.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18261
This commit is contained in:
parent
0b4d0bcb6c
commit
968ef0082d
|
@ -200,7 +200,18 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
|
|
||||||
// Copy picker list:
|
// Copy picker list:
|
||||||
if( !commandToUndo->GetCount() )
|
if( !commandToUndo->GetCount() )
|
||||||
|
{
|
||||||
commandToUndo->CopyList( aItemsList );
|
commandToUndo->CopyList( aItemsList );
|
||||||
|
|
||||||
|
for( const std::unique_ptr<SCH_ITEM>& item : GetRepeatItems() )
|
||||||
|
{
|
||||||
|
EDA_ITEM* repeatItemClone = item->Clone();
|
||||||
|
repeatItemClone->SetFlags( UR_TRANSIENT );
|
||||||
|
|
||||||
|
ITEM_PICKER repeatItemPicker( nullptr, repeatItemClone, UNDO_REDO::REPEAT_ITEM );
|
||||||
|
commandToUndo->PushItem( repeatItemPicker );
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Unless we are appending, in which case, get the picker items
|
// Unless we are appending, in which case, get the picker items
|
||||||
|
@ -242,6 +253,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
case UNDO_REDO::NEWITEM:
|
case UNDO_REDO::NEWITEM:
|
||||||
case UNDO_REDO::DELETED:
|
case UNDO_REDO::DELETED:
|
||||||
case UNDO_REDO::PAGESETTINGS:
|
case UNDO_REDO::PAGESETTINGS:
|
||||||
|
case UNDO_REDO::REPEAT_ITEM:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -275,6 +287,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
||||||
bool rebuildHierarchyNavigator = false;
|
bool rebuildHierarchyNavigator = false;
|
||||||
SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
|
SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
|
||||||
SCH_SHEET_LIST sheets;
|
SCH_SHEET_LIST sheets;
|
||||||
|
bool clearedRepeatItems = false;
|
||||||
|
|
||||||
// Undo in the reverse order of list creation: (this can allow stacked changes like the
|
// Undo in the reverse order of list creation: (this can allow stacked changes like the
|
||||||
// same item can be changed and deleted in the same complex command).
|
// same item can be changed and deleted in the same complex command).
|
||||||
|
@ -285,8 +298,6 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
||||||
EDA_ITEM* eda_item = aList->GetPickedItem( ii );
|
EDA_ITEM* eda_item = aList->GetPickedItem( ii );
|
||||||
SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( aList->GetScreenForItem( ii ) );
|
SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( aList->GetScreenForItem( ii ) );
|
||||||
|
|
||||||
wxCHECK( screen, /* void */ );
|
|
||||||
|
|
||||||
eda_item->SetFlags( aList->GetPickerFlags( ii ) );
|
eda_item->SetFlags( aList->GetPickerFlags( ii ) );
|
||||||
eda_item->ClearEditFlags();
|
eda_item->ClearEditFlags();
|
||||||
eda_item->ClearTempFlags();
|
eda_item->ClearTempFlags();
|
||||||
|
@ -390,6 +401,17 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
||||||
item->Restore( this );
|
item->Restore( this );
|
||||||
*item = std::move( alt_item );
|
*item = std::move( alt_item );
|
||||||
}
|
}
|
||||||
|
else if( status == UNDO_REDO::REPEAT_ITEM )
|
||||||
|
{
|
||||||
|
if( !clearedRepeatItems )
|
||||||
|
{
|
||||||
|
ClearRepeatItemsList();
|
||||||
|
clearedRepeatItems = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( schItem )
|
||||||
|
AddCopyForRepeatItem( schItem );
|
||||||
|
}
|
||||||
else if( schItem )
|
else if( schItem )
|
||||||
{
|
{
|
||||||
SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
|
SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
|
||||||
|
|
|
@ -70,7 +70,8 @@ enum class UNDO_REDO {
|
||||||
PAGESETTINGS, // page settings or title block changes
|
PAGESETTINGS, // page settings or title block changes
|
||||||
REGROUP, // new group of items created (NB: can't use GROUP because of collision
|
REGROUP, // new group of items created (NB: can't use GROUP because of collision
|
||||||
// with a header on msys2)
|
// with a header on msys2)
|
||||||
UNGROUP // existing group destroyed (items not destroyed)
|
UNGROUP, // existing group destroyed (items not destroyed)
|
||||||
|
REPEAT_ITEM // storage entry for the editor's global repeatItems list
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue