Some fixes related to translated/not translated mandatory field names.

DIALOG_SYMBOL_FIELDS_TABLE: add new fields to symbols only if the field is not empty.

(cherry picked from commit 45b167dff5)
This commit is contained in:
jean-pierre charras 2022-05-13 11:39:16 +02:00 committed by Seth Hillbrand
parent f663b42d77
commit 46b3188737
4 changed files with 25 additions and 12 deletions

View File

@ -53,8 +53,6 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const
{
wxASSERT( aTextItem );
SetTitle( aTitle );
m_note->SetFont( KIUI::GetInfoFont( this ).Italic() );
m_note->Show( false );
@ -348,7 +346,14 @@ DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES( SCH_BASE_FRAME* aParen
m_isPower = false;
m_textLabel->SetLabel( m_field->GetName() + wxT( ":" ) );
wxString translated_fieldname;
if( m_field->GetId() < MANDATORY_FIELDS )
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( m_field->GetId(), DO_TRANSLATE );
else
translated_fieldname = m_field->GetName();
m_textLabel->SetLabel( translated_fieldname + ":" );
m_position = m_field->GetPosition();

View File

@ -236,7 +236,7 @@ public:
// FIX ME: the column label should be displayed translated.
// but when translated, and the DATASHEET column is shown, a new field
// with the translated DATASHEET field name is added when saving fields
// return TEMPLATE_FIELDNAME::GetDefaultFieldName( aCol DO_TRANSLATE );
// return TEMPLATE_FIELDNAME::GetDefaultFieldName( aCol, DO_TRANSLATE );
return TEMPLATE_FIELDNAME::GetDefaultFieldName( aCol );
else
return m_fieldNames[ aCol ];
@ -619,19 +619,21 @@ public:
const wxString& srcValue = srcData.second;
SCH_FIELD* destField = symbol.FindField( srcName );
if( !destField && !srcValue.IsEmpty() )
// Add a not existing field if it has a value for this symbol
bool createField = !destField && !srcValue.IsEmpty();
if( createField )
{
const wxPoint symbolPos = symbol.GetPosition();
destField = symbol.AddField( SCH_FIELD( symbolPos, -1, &symbol, srcName ) );
}
if( !destField )
continue;
if( destField->GetId() == REFERENCE_FIELD )
{
symbol.RemoveField( srcName );
}
else if( destField->GetId() == REFERENCE_FIELD )
{
// Reference is not editable
// Reference is not editable from this dialog
}
else if( destField->GetId() == VALUE_FIELD )
{

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Oliver Walters
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -74,6 +74,8 @@ private:
SCH_REFERENCE_LIST m_symbolsList;
FIELDS_EDITOR_GRID_DATA_MODEL* m_dataModel;
static int m_newFieldsOption; // Store the option choice for new fields
// during a session:
};
#endif /* DIALOG_SYMBOL_FIELDS_TABLE_H */

View File

@ -1122,7 +1122,11 @@ void SCH_EDIT_TOOL::editFieldText( SCH_FIELD* aField )
// Use title caps for mandatory fields. "Edit Sheet name Field" looks dorky.
if( parentType == SCH_SYMBOL_T && aField->GetId() < MANDATORY_FIELDS )
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
{
wxString translated_fieldname;
translated_fieldname = TEMPLATE_FIELDNAME::GetDefaultFieldName( aField->GetId(), DO_TRANSLATE );
caption.Printf( _( "Edit %s Field" ), TitleCaps( translated_fieldname ) );
}
else if( parentType == SCH_SHEET_T && aField->GetId() < SHEET_MANDATORY_FIELDS )
caption.Printf( _( "Edit %s Field" ), TitleCaps( aField->GetName() ) );
else