Remove requirement that non-power symbols share a name and value
There is no technical reason for this restriction for non-power symbols, so let's remove it. This will allow more flexibility and compatibility with other tools. Fixes https://gitlab.com/kicad/code/kicad/-/issues/9389
This commit is contained in:
parent
af34835fdf
commit
8694c37376
|
@ -305,8 +305,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
if( !m_grid->CommitPendingChanges() )
|
||||
return false;
|
||||
|
||||
// We need to keep the name and the value the same at the moment!
|
||||
wxString newName = EscapeString( m_fields->at( VALUE_FIELD ).GetText(), CTX_LIBID );
|
||||
wxString newName = EscapeString( m_SymbolNameCtrl->GetValue(), CTX_LIBID );
|
||||
wxString oldName = m_libEntry->GetName();
|
||||
|
||||
if( oldName != newName )
|
||||
|
@ -363,7 +362,6 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
m_libEntry->SetParent( newParent );
|
||||
}
|
||||
|
||||
// We need to keep the name and the value the same at the moment!
|
||||
m_libEntry->SetName( newName );
|
||||
m_libEntry->SetDescription( m_DescCtrl->GetValue() );
|
||||
m_libEntry->SetKeyWords( m_KeywordCtrl->GetValue() );
|
||||
|
@ -374,9 +372,15 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
m_Parent->SetShowDeMorgan( m_AsConvertButt->GetValue() );
|
||||
|
||||
if( m_OptionPower->GetValue() )
|
||||
{
|
||||
m_libEntry->SetPower();
|
||||
// Power symbols must have value matching name for now
|
||||
m_libEntry->GetValueField().SetText( newName );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_libEntry->SetNormal();
|
||||
}
|
||||
|
||||
m_libEntry->SetIncludeInBom( !m_excludeFromBomCheckBox->GetValue() );
|
||||
m_libEntry->SetIncludeOnBoard( !m_excludeFromBoardCheckBox->GetValue() );
|
||||
|
@ -442,10 +446,6 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
|
|||
}
|
||||
}
|
||||
}
|
||||
else if( event.GetRow() == VALUE_FIELD && event.GetCol() == FDC_VALUE )
|
||||
{
|
||||
m_SymbolNameCtrl->ChangeValue( event.GetString() );
|
||||
}
|
||||
|
||||
editor->DecRef();
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event )
|
|||
|
||||
void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event )
|
||||
{
|
||||
if( !m_Parent->IsSymbolFromSchematic() || m_OptionPower->IsChecked() )
|
||||
if( m_OptionPower->IsChecked() )
|
||||
m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() );
|
||||
}
|
||||
|
||||
|
@ -736,7 +736,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
|
|||
int row = m_grid->GetGridCursorRow();
|
||||
int col = m_grid->GetGridCursorCol();
|
||||
|
||||
if( row == VALUE_FIELD && col == FDC_VALUE )
|
||||
if( row == VALUE_FIELD && col == FDC_VALUE && m_OptionPower->IsChecked() )
|
||||
{
|
||||
wxGridCellEditor* editor = m_grid->GetCellEditor( row, col );
|
||||
m_SymbolNameCtrl->ChangeValue( editor->GetValue() );
|
||||
|
|
|
@ -681,11 +681,6 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
|
|||
for( unsigned i = 0; i < m_fields->size(); ++i )
|
||||
m_fields->at( i ).Offset( m_symbol->GetPosition() );
|
||||
|
||||
LIB_SYMBOL* entry = GetParent()->GetLibSymbol( m_symbol->GetLibId() );
|
||||
|
||||
if( entry && entry->IsPower() )
|
||||
m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() );
|
||||
|
||||
SCH_FIELDS& fields = m_symbol->GetFields();
|
||||
|
||||
fields.clear();
|
||||
|
|
|
@ -365,6 +365,7 @@ void LIB_SYMBOL::SetName( const wxString& aName )
|
|||
m_name = aName;
|
||||
m_libId.SetLibItemName( aName );
|
||||
|
||||
if( IsPower() )
|
||||
GetValueField().SetText( aName );
|
||||
}
|
||||
|
||||
|
|
|
@ -871,9 +871,6 @@ void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, b
|
|||
}
|
||||
else if( id == VALUE_FIELD )
|
||||
{
|
||||
if( aResetOtherFields )
|
||||
SetValue( aPath, UnescapeString( m_lib_id.GetLibItemName() ) ); // alias-specific value
|
||||
else
|
||||
SetValue( aPath, UnescapeString( libField->GetText() ) );
|
||||
}
|
||||
else if( id == FOOTPRINT_FIELD )
|
||||
|
|
|
@ -480,6 +480,7 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol()
|
|||
break;
|
||||
|
||||
case VALUE_FIELD:
|
||||
if( parent->IsPower() )
|
||||
field->SetText( name );
|
||||
break;
|
||||
|
||||
|
|
|
@ -527,11 +527,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField )
|
|||
LIB_SYMBOL* parent = aField->GetParent();
|
||||
wxCHECK( parent, /* void */ );
|
||||
|
||||
// Editing the symbol value field is equivalent to creating a new symbol based on the
|
||||
// current symbol. Set the dialog message to inform the user.
|
||||
if( aField->GetId() == VALUE_FIELD )
|
||||
caption = _( "Edit Symbol Name" );
|
||||
else if( aField->GetId() < MANDATORY_FIELDS )
|
||||
if( aField->GetId() < MANDATORY_FIELDS )
|
||||
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
|
||||
else
|
||||
caption.Printf( _( "Edit '%s' Field" ), aField->GetName() );
|
||||
|
@ -545,28 +541,16 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField )
|
|||
|
||||
wxString newFieldValue = EscapeString( dlg.GetText(), CTX_LIBID );
|
||||
wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() );
|
||||
bool renamed = aField->GetId() == VALUE_FIELD && newFieldValue != oldFieldValue;
|
||||
|
||||
if( renamed )
|
||||
saveCopyInUndoList( parent, UNDO_REDO::LIB_RENAME );
|
||||
else
|
||||
saveCopyInUndoList( parent, UNDO_REDO::LIBEDIT );
|
||||
|
||||
dlg.UpdateField( aField );
|
||||
|
||||
if( renamed )
|
||||
{
|
||||
parent->SetName( newFieldValue );
|
||||
m_frame->UpdateAfterSymbolProperties( &oldFieldValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
updateItem( aField, true );
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
m_frame->OnModify();
|
||||
m_frame->UpdateSymbolMsgPanelInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties()
|
||||
|
|
Loading…
Reference in New Issue