From b71fae013c8387f770b3c443dd6761fbd3738b86 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 6 Jan 2018 12:36:08 +0000 Subject: [PATCH 2/4] Keep value, footprint and datasheet in sync in multi-unit parts MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.14.3 (Apple Git-98)" This is a multi-part message in MIME format. --------------2.14.3 (Apple Git-98) Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Fixes: lp:1731743 * https://bugs.launchpad.net/kicad/+bug/1731743 --- .../dialogs/dialog_edit_component_in_schematic.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) --------------2.14.3 (Apple Git-98) Content-Type: text/x-patch; name="0002-Keep-value-footprint-and-datasheet-in-sync-in-multi-.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0002-Keep-value-footprint-and-datasheet-in-sync-in-multi-.patch" diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index e8d1d9d64..b5575eff3 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -509,6 +510,31 @@ 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(); + 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(); --------------2.14.3 (Apple Git-98)--