Keep value, footprint and datasheet in sync in multi-unit parts

Fixes: lp:1731743
* https://bugs.launchpad.net/kicad/+bug/1731743
This commit is contained in:
Jeff Young 2018-01-06 12:36:08 +00:00 committed by Wayne Stambaugh
parent 6436b70176
commit c6d0075076
1 changed files with 27 additions and 0 deletions

View File

@ -38,6 +38,7 @@
#include <general.h>
#include <sch_base_frame.h>
#include <sch_reference_list.h>
#include <class_library.h>
#include <sch_component.h>
#include <dialog_helpers.h>
@ -509,6 +510,32 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
// reference.
m_cmp->SetRef( &GetParent()->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
// The value, footprint and datasheet fields should be kept in sync in multi-unit
// parts.
if( m_cmp->GetUnitCount() > 1 )
{
const LIB_ID thisLibId = m_cmp->GetLibId();
const wxString thisRef = m_cmp->GetRef( &( GetParent()->GetCurrentSheet() ) );
int thisUnit = m_cmp->GetUnit();
SCH_REFERENCE_LIST components;
GetParent()->GetCurrentSheet().GetComponents( components );
for( int i = 0; i < components.GetCount(); i++ )
{
SCH_REFERENCE component = components[i];
if( component.GetLibPart()->GetLibId() == thisLibId
&& component.GetRef() == thisRef
&& component.GetUnit() != thisUnit )
{
SCH_COMPONENT* otherUnit = component.GetComp();
GetParent()->SaveCopyInUndoList( otherUnit, UR_CHANGED, true /* append */);
otherUnit->GetField( VALUE )->SetText( m_FieldsBuf[VALUE].GetText() );
otherUnit->GetField( FOOTPRINT )->SetText( m_FieldsBuf[FOOTPRINT].GetText() );
otherUnit->GetField( DATASHEET )->SetText( m_FieldsBuf[DATASHEET].GetText() );
}
}
}
GetParent()->OnModify();
GetParent()->GetScreen()->TestDanglingEnds();