Draw datasheet field with the value from the dfm file.

Fixes: lp:1841369
* https://bugs.launchpad.net/kicad/+bug/1841369
This commit is contained in:
Jeff Young 2019-08-25 21:50:33 +01:00
parent de8f97be6b
commit 80dd3f8635
4 changed files with 23 additions and 8 deletions

View File

@ -1112,22 +1112,34 @@ void LIB_PART::RemoveAllAliases()
}
LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName ) const
{
wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
wxT( "Cannot get alias with an empty name. Bad programmer!" ) );
for( size_t i = 0; i < m_aliases.size(); i++ )
for( LIB_ALIAS* alias : m_aliases)
{
if( aName == m_aliases[i]->GetName() )
return m_aliases[i];
if( alias->GetName() == aName )
return alias;
}
return NULL;
}
LIB_ALIAS* LIB_PART::GetAlias( size_t aIndex )
LIB_ALIAS* LIB_PART::GetRootAlias() const
{
for( LIB_ALIAS* alias : m_aliases )
{
if( alias->IsRoot() )
return alias;
}
return NULL;
}
LIB_ALIAS* LIB_PART::GetAlias( size_t aIndex ) const
{
wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
wxT( "Illegal alias list index, bad programmer." ) );

View File

@ -281,8 +281,9 @@ public:
size_t GetAliasCount() const { return m_aliases.size(); }
LIB_ALIAS* GetAlias( size_t aIndex );
LIB_ALIAS* GetAlias( const wxString& aName );
LIB_ALIAS* GetAlias( size_t aIndex ) const;
LIB_ALIAS* GetAlias( const wxString& aName ) const;
LIB_ALIAS* GetRootAlias() const;
timestamp_t GetDateLastEdition() const { return m_dateLastEdition; }

View File

@ -330,7 +330,6 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::TransferDataFromWindow()
// Datasheet field is special; copy it to the root alias docfilename
rootAlias->SetDocFileName( m_fields->at( DATASHEET ).GetText() );
m_fields->at( DATASHEET ).SetText( wxEmptyString );
m_libEntry->SetFields( *m_fields );

View File

@ -406,6 +406,9 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart )
{
delete m_my_part;
m_my_part = aPart;
// Datasheet field is special; copy it to the root alias docfilename
m_my_part->GetField( DATASHEET )->SetText( aPart->GetRootAlias()->GetDocFileName() );
}
// select the current component in the tree widget