sch groups: clear group membership on destruction, add tests

This commit is contained in:
Mike Williams
2025-04-15 10:14:38 -04:00
parent 718bf40807
commit 5db091fc79
9 changed files with 191 additions and 5 deletions
+34 -1
View File
@@ -1847,7 +1847,8 @@ void SCH_SELECTION_TOOL::GuessSelectionCandidates( SCH_COLLECTOR& collector, con
SCH_SELECTION& SCH_SELECTION_TOOL::RequestSelection( const std::vector<KICAD_T>& aScanTypes,
bool aPromoteCellSelections )
bool aPromoteCellSelections,
bool aPromoteGroups )
{
bool anyUnselected = false;
bool anySelected = false;
@@ -1881,6 +1882,38 @@ SCH_SELECTION& SCH_SELECTION_TOOL::RequestSelection( const std::vector<KICAD_T>&
updateReferencePoint();
}
if( aPromoteGroups )
{
for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i )
{
EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
std::set<EDA_ITEM*> selectedChildren;
if( item->Type() == SCH_GROUP_T )
{
static_cast<SCH_ITEM*>(item)
->RunOnChildren( [&]( SCH_ITEM* item )
{
if( item->IsType( aScanTypes ) )
selectedChildren.insert( item );
},
RECURSE_MODE::RECURSE );
unselect( item );
anyUnselected = true;
}
for( EDA_ITEM* child : selectedChildren )
{
if( !child->IsSelected() )
{
select( child );
anySelected = true;
}
}
}
}
if( aPromoteCellSelections )
{
std::set<EDA_ITEM*> parents;