add support to update an already existing field

This commit is contained in:
afkiwers 2024-04-08 09:45:43 +10:00 committed by Jon Evans
parent e2f1da60d9
commit d45911f54b
1 changed files with 24 additions and 7 deletions

View File

@ -458,15 +458,32 @@ LIB_SYMBOL* SCH_IO_HTTP_LIB::loadSymbolFromPart( const wxString& aSymbo
}
else
{
// Generic fields
field = new LIB_FIELD( symbol->GetNextAvailableFieldId() );
field->SetName( fieldName );
// Check if field exists, if so replace Text and adjust visiblity.
//
// This proves useful in situations where, for instance, an individual requires a particular value, such as
// the material type showcased at a specific position for a capacitor. Subsequently, this value could be defined
// in the symbol itself and then, potentially, be modified by the HTTP library as necessary.
field = symbol->FindField( fieldName );
field->SetText( std::get<0>( fieldProperties ) );
field->SetVisible( std::get<1>( fieldProperties ) );
symbol->AddField( field );
if( field != nullptr )
{
// adjust values accordingly
field->SetText( std::get<0>( fieldProperties ) );
field->SetVisible( std::get<1>( fieldProperties ) );
}
else
{
// Generic fields
field = new LIB_FIELD( symbol->GetNextAvailableFieldId() );
field->SetName( fieldName );
field->SetText( std::get<0>( fieldProperties ) );
field->SetVisible( std::get<1>( fieldProperties ) );
symbol->AddField( field );
m_customFields.insert( fieldName );
}
m_customFields.insert( fieldName );
}
}