Hierarchy: update just selection on sheet change

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/11550
This commit is contained in:
Mike Williams 2022-05-03 15:34:50 -04:00 committed by Seth Hillbrand
parent 8524042352
commit e811b9a2dd
2 changed files with 35 additions and 1 deletions

View File

@ -205,6 +205,34 @@ void HIERARCHY_NAVIG_DLG::buildHierarchyTree( SCH_SHEET_PATH* aList, wxTreeItemI
}
void HIERARCHY_NAVIG_DLG::UpdateHierarchySelection()
{
m_currSheet = m_SchFrameEditor->GetCurrentSheet();
std::function<void( const wxTreeItemId& )> selectSheet = [&]( const wxTreeItemId& id )
{
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
TreeItemData* itemData = static_cast<TreeItemData*>( m_Tree->GetItemData( id ) );
if( itemData->m_SheetPath == m_currSheet )
{
m_Tree->EnsureVisible( id );
m_Tree->SelectItem( id );
}
wxTreeItemIdValue cookie = id;
wxTreeItemId child = m_Tree->GetFirstChild( id, cookie );
while( child.IsOk() )
{
selectSheet( child );
child = m_Tree->GetNextChild( child, cookie );
}
};
selectSheet( m_Tree->GetRootItem() );
}
void HIERARCHY_NAVIG_DLG::UpdateHierarchyTree()
{
Freeze();
@ -315,5 +343,6 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
TOOL_EVENT dummy;
editTool->UpdateNetHighlighting( dummy );
UpdateHierarchyNavigator();
if( FindHierarchyNavigator() )
FindHierarchyNavigator()->UpdateHierarchySelection();
}

View File

@ -76,6 +76,11 @@ public:
*/
void UpdateHierarchyTree();
/**
* Updates the tree's selection to match current page
*/
void UpdateHierarchySelection();
private:
/**
* Create the hierarchical tree of the schematic.