Handle mandatory fields name translated and not translated in SCH_COMPONENT::GetFieldText.
Fixes #9520 https://gitlab.com/kicad/code/kicad/issues/9520
This commit is contained in:
parent
d87e5cb809
commit
79028f1627
|
@ -922,6 +922,11 @@ wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME
|
||||||
{
|
{
|
||||||
if( aFieldName == m_Fields[ii].GetName() )
|
if( aFieldName == m_Fields[ii].GetName() )
|
||||||
return m_Fields[ii].GetText();
|
return m_Fields[ii].GetText();
|
||||||
|
|
||||||
|
if( ii < MANDATORY_FIELDS && aFieldName == TEMPLATE_FIELDNAME::GetCanonicalFieldName( ii ) )
|
||||||
|
{
|
||||||
|
return m_Fields[ii].GetText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
|
@ -31,6 +31,36 @@
|
||||||
using namespace TFIELD_T;
|
using namespace TFIELD_T;
|
||||||
|
|
||||||
|
|
||||||
|
const wxString TEMPLATE_FIELDNAME::GetCanonicalFieldName( int aFieldNdx )
|
||||||
|
{
|
||||||
|
// Fixed values for the first few default fields used by EESCHEMA
|
||||||
|
// (mandatory fields)
|
||||||
|
switch( aFieldNdx )
|
||||||
|
{
|
||||||
|
case REFERENCE:
|
||||||
|
return wxT( "Reference" ); // The component reference, R1, C1, etc.
|
||||||
|
|
||||||
|
case VALUE:
|
||||||
|
return wxT( "Value" ); // The component value + name
|
||||||
|
|
||||||
|
case FOOTPRINT:
|
||||||
|
return wxT( "Footprint" ); // The footprint for use with Pcbnew
|
||||||
|
|
||||||
|
case DATASHEET:
|
||||||
|
return wxT( "Datasheet" ); // Link to a datasheet for component
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other fields are use fields, give a default name:
|
||||||
|
wxString fieldName = wxT( "Field" );
|
||||||
|
fieldName << aFieldNdx;
|
||||||
|
return fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
|
const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
|
||||||
{
|
{
|
||||||
static void* locale = nullptr;
|
static void* locale = nullptr;
|
||||||
|
@ -52,6 +82,8 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
|
||||||
locale = Pgm().GetLocale();
|
locale = Pgm().GetLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixed values for the first few default fields used by EESCHEMA
|
||||||
|
|
||||||
// Fixed values for the first few default fields used by EESCHEMA
|
// Fixed values for the first few default fields used by EESCHEMA
|
||||||
// (mandatory fields)
|
// (mandatory fields)
|
||||||
switch( aFieldNdx )
|
switch( aFieldNdx )
|
||||||
|
@ -78,6 +110,7 @@ const wxString TEMPLATE_FIELDNAME::GetDefaultFieldName( int aFieldNdx )
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
void TEMPLATE_FIELDNAME::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
||||||
{
|
{
|
||||||
out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
|
out->Print( nestLevel, "(field (name %s)", out->Quotew( m_Name ).c_str() );
|
||||||
|
|
|
@ -122,6 +122,14 @@ struct TEMPLATE_FIELDNAME
|
||||||
* @param aFieldNdx The field number index, > 0
|
* @param aFieldNdx The field number index, > 0
|
||||||
*/
|
*/
|
||||||
static const wxString GetDefaultFieldName( int aFieldNdx );
|
static const wxString GetDefaultFieldName( int aFieldNdx );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a not translated default symbol field name for field \a aFieldNdx
|
||||||
|
* for all components.
|
||||||
|
* These fieldnames are not modifiable, but template fieldnames are.
|
||||||
|
* @param aFieldNdx The field number index, > 0
|
||||||
|
*/
|
||||||
|
static const wxString GetCanonicalFieldName( int aFieldNdx );
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
|
typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
|
||||||
|
|
Loading…
Reference in New Issue