HIERARCHY_PANE: Update tree labels when editing a sheet name or number
Fixes #16650 https://gitlab.com/kicad/code/kicad/-/issues/16650
This commit is contained in:
parent
a2b204572d
commit
2e760483b0
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com
|
||||||
* Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
|
* Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com
|
||||||
* Copyright (C) 2004-2023 KiCad Developers, see AITHORS.txt for contributors.
|
* Copyright (C) 2004-2024 KiCad Developers, see AITHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -617,6 +617,12 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* a
|
||||||
// convert any text variable cross-references to their UUIDs
|
// convert any text variable cross-references to their UUIDs
|
||||||
m_text = aField->Schematic()->ConvertRefsToKIIDs( m_text );
|
m_text = aField->Schematic()->ConvertRefsToKIIDs( m_text );
|
||||||
|
|
||||||
|
// Changing a sheetname need to update the hierarchy navigator
|
||||||
|
bool needUpdateHierNav = false;
|
||||||
|
|
||||||
|
if( parent && parent->Type() == SCH_SHEET_T && fieldType == SHEETNAME )
|
||||||
|
needUpdateHierNav = m_text != aField->GetText();
|
||||||
|
|
||||||
aField->SetText( m_text );
|
aField->SetText( m_text );
|
||||||
updateText( aField );
|
updateText( aField );
|
||||||
aField->SetPosition( m_position );
|
aField->SetPosition( m_position );
|
||||||
|
@ -676,4 +682,8 @@ void DIALOG_SCH_FIELD_PROPERTIES::UpdateField( SCH_COMMIT* aCommit, SCH_FIELD* a
|
||||||
|
|
||||||
if( positioningModified && parent )
|
if( positioningModified && parent )
|
||||||
parent->ClearFieldsAutoplaced();
|
parent->ClearFieldsAutoplaced();
|
||||||
|
|
||||||
|
//Update the hierarchy navigator labels if needed
|
||||||
|
if( needUpdateHierNav )
|
||||||
|
editFrame->UpdateLabelsHierarchyNavigator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1143,6 +1143,14 @@ void SCH_EDIT_FRAME::UpdateHierarchyNavigator()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_EDIT_FRAME::UpdateLabelsHierarchyNavigator()
|
||||||
|
{
|
||||||
|
// Update only the hierarchy navigation tree labels.
|
||||||
|
// The tree list is expectyed to be up to date
|
||||||
|
m_hierarchy->UpdateLabelsHierarchyTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::UpdateHierarchySelection()
|
void SCH_EDIT_FRAME::UpdateHierarchySelection()
|
||||||
{
|
{
|
||||||
m_hierarchy->UpdateHierarchySelection();
|
m_hierarchy->UpdateHierarchySelection();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras wanadoo.fr
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras wanadoo.fr
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2023 CERN (www.cern.ch)
|
* Copyright (C) 2023 CERN (www.cern.ch)
|
||||||
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -233,6 +233,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateHierarchyNavigator();
|
void UpdateHierarchyNavigator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the hierarchy navigation tree labels.
|
||||||
|
* No change for the tree, only the labels are updated, after editing a sheet
|
||||||
|
* name or a sheet number.
|
||||||
|
*/
|
||||||
|
void UpdateLabelsHierarchyNavigator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy
|
* Update the hierarchy navigation tree selection (cross-probe from schematic to hierarchy
|
||||||
* pane).
|
* pane).
|
||||||
|
|
|
@ -2496,6 +2496,10 @@ int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
|
// Update the hierarchy navigator labels if needed
|
||||||
|
if( pageNumber != dlg.GetValue() )
|
||||||
|
m_frame->UpdateLabelsHierarchyNavigator();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,45 @@ void HIERARCHY_PANE::onSelectSheetPath( wxTreeEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HIERARCHY_PANE::UpdateLabelsHierarchyTree()
|
||||||
|
{
|
||||||
|
// Update the labels of the hierarchical tree of the schematic.
|
||||||
|
// Must be called only for an up to date tree, to update displayed labels after
|
||||||
|
// a sheet name or a sheet number change.
|
||||||
|
|
||||||
|
std::function<void( const wxTreeItemId& )> updateLabel =
|
||||||
|
[&]( const wxTreeItemId& id )
|
||||||
|
{
|
||||||
|
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
|
||||||
|
SCH_SHEET* sheet = itemData->m_SheetPath.Last();
|
||||||
|
wxString sheetNameLabel = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
|
||||||
|
itemData->m_SheetPath.GetPageNumber() );
|
||||||
|
if( m_tree->GetItemText( id ) != sheetNameLabel )
|
||||||
|
m_tree->SetItemText( id, sheetNameLabel );
|
||||||
|
};
|
||||||
|
|
||||||
|
wxTreeItemId rootId = m_tree->GetRootItem();
|
||||||
|
updateLabel( rootId );
|
||||||
|
|
||||||
|
std::function<void( const wxTreeItemId& )> recursiveDescent =
|
||||||
|
[&]( const wxTreeItemId& id )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
|
||||||
|
wxTreeItemIdValue cookie;
|
||||||
|
wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
|
||||||
|
|
||||||
|
while( child.IsOk() )
|
||||||
|
{
|
||||||
|
updateLabel( child );
|
||||||
|
recursiveDescent( child );
|
||||||
|
child = m_tree->GetNextChild( id, cookie );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recursiveDescent( rootId );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void HIERARCHY_PANE::onRightClick( wxTreeEvent& aEvent )
|
void HIERARCHY_PANE::onRightClick( wxTreeEvent& aEvent )
|
||||||
{
|
{
|
||||||
wxTreeItemId itemSel = aEvent.GetItem();
|
wxTreeItemId itemSel = aEvent.GetItem();
|
||||||
|
@ -310,6 +349,8 @@ void HIERARCHY_PANE::onRightClick( wxTreeEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
|
||||||
|
UpdateLabelsHierarchyTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2022 Mike Williams <mike at mikebwilliams.com>
|
* Copyright (C) 2022 Mike Williams <mike at mikebwilliams.com>
|
||||||
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -81,6 +81,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateHierarchySelection();
|
void UpdateHierarchySelection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the labels of the hierarchical tree of the schematic.
|
||||||
|
* Must be called only for an up to date tree, to update displayed labels after
|
||||||
|
* a sheet name or a sheet number change.
|
||||||
|
*/
|
||||||
|
void UpdateLabelsHierarchyTree();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Create the hierarchical tree of the schematic.
|
* Create the hierarchical tree of the schematic.
|
||||||
|
|
Loading…
Reference in New Issue