Field Name Template (aka Default Fields) fixes.
Move from a "default" fields model to a "seed" fields model. See discussion on devlist: https://lists.launchpad.net/kicad-developers/msg35823.html.
This commit is contained in:
parent
8c63dac0c3
commit
d03e92a3a2
|
@ -824,12 +824,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
|
|||
// values from the component will be set.
|
||||
if( !schField )
|
||||
{
|
||||
if( !it->m_Visible )
|
||||
fld.SetVisible( false );
|
||||
else
|
||||
fld.SetVisible( true );
|
||||
|
||||
fld.SetText( it->m_Value ); // empty? ok too.
|
||||
fld.SetVisible( it->m_Visible );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -650,12 +650,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
|
|||
if( !libField )
|
||||
{
|
||||
fld.SetName( it->m_Name );
|
||||
fld.SetText( it->m_Value ); // empty? ok too.
|
||||
|
||||
if( !it->m_Visible )
|
||||
fld.SetVisible( false );
|
||||
else
|
||||
fld.SetVisible( true );
|
||||
fld.SetVisible( it->m_Visible );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -207,7 +207,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
|
|||
|
||||
// Add a new fieldname to the fieldname list
|
||||
TEMPLATE_FIELDNAME newFieldname = TEMPLATE_FIELDNAME( "Fieldname" );
|
||||
newFieldname.m_Value = wxT( "Value" );
|
||||
newFieldname.m_Visible = false;
|
||||
templateFields.insert( pos, newFieldname );
|
||||
TransferDataToFieldGrid();
|
||||
|
@ -345,18 +344,15 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToFieldGrid()
|
|||
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
|
||||
{
|
||||
m_fieldGrid->SetCellValue( row, 0, templateFields[row].m_Name );
|
||||
m_fieldGrid->SetCellValue( row, 1, templateFields[row].m_Value );
|
||||
m_fieldGrid->SetCellValue( row, 2,
|
||||
templateFields[row].m_Visible ? wxT( "1" ) : wxEmptyString );
|
||||
m_fieldGrid->SetCellValue( row, 1, templateFields[row].m_Visible ? wxT( "1" ) : wxEmptyString );
|
||||
|
||||
// Set cell properties
|
||||
m_fieldGrid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
|
||||
m_fieldGrid->SetCellAlignment( row, 1, wxALIGN_LEFT, wxALIGN_CENTRE );
|
||||
|
||||
// Render the Visible column as a check box
|
||||
m_fieldGrid->SetCellEditor( row, 2, new wxGridCellBoolEditor() );
|
||||
m_fieldGrid->SetCellRenderer( row, 2, new wxGridCellBoolRenderer() );
|
||||
m_fieldGrid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
m_fieldGrid->SetCellEditor( row, 1, new wxGridCellBoolEditor() );
|
||||
m_fieldGrid->SetCellRenderer( row, 1, new wxGridCellBoolRenderer() );
|
||||
m_fieldGrid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
}
|
||||
|
||||
m_fieldGrid->AutoSizeRows();
|
||||
|
@ -374,8 +370,7 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataFromFieldGrid()
|
|||
for( int row = 0; row < m_fieldGrid->GetNumberRows(); ++row )
|
||||
{
|
||||
templateFields[row].m_Name = m_fieldGrid->GetCellValue( row, 0 );
|
||||
templateFields[row].m_Value = m_fieldGrid->GetCellValue( row, 1 );
|
||||
templateFields[row].m_Visible = ( m_fieldGrid->GetCellValue( row, 2 ) != wxEmptyString );
|
||||
templateFields[row].m_Visible = ( m_fieldGrid->GetCellValue( row, 1 ) != wxEmptyString );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -327,24 +327,20 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
|
|||
m_fieldGrid = new wxGrid( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
// Grid
|
||||
m_fieldGrid->CreateGrid( 0, 3 );
|
||||
m_fieldGrid->CreateGrid( 0, 2 );
|
||||
m_fieldGrid->EnableEditing( true );
|
||||
m_fieldGrid->EnableGridLines( true );
|
||||
m_fieldGrid->EnableDragGridSize( false );
|
||||
m_fieldGrid->SetMargins( 0, 0 );
|
||||
|
||||
// Columns
|
||||
m_fieldGrid->SetColSize( 0, 150 );
|
||||
m_fieldGrid->SetColSize( 1, 150 );
|
||||
m_fieldGrid->SetColSize( 2, 75 );
|
||||
m_fieldGrid->SetColSize( 0, 300 );
|
||||
m_fieldGrid->SetColSize( 1, 75 );
|
||||
m_fieldGrid->EnableDragColMove( false );
|
||||
m_fieldGrid->EnableDragColSize( true );
|
||||
m_fieldGrid->SetColLabelSize( 30 );
|
||||
m_fieldGrid->SetColLabelSize( 22 );
|
||||
m_fieldGrid->SetColLabelValue( 0, _("Name") );
|
||||
m_fieldGrid->SetColLabelValue( 1, _("Default Value") );
|
||||
m_fieldGrid->SetColLabelValue( 2, _("Visible") );
|
||||
m_fieldGrid->SetColLabelValue( 3, _("Name") );
|
||||
m_fieldGrid->SetColLabelValue( 4, wxEmptyString );
|
||||
m_fieldGrid->SetColLabelValue( 1, _("Visible") );
|
||||
m_fieldGrid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
||||
|
||||
// Rows
|
||||
|
@ -380,7 +376,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
|
|||
m_panel2->SetSizer( bSizer6 );
|
||||
m_panel2->Layout();
|
||||
bSizer6->Fit( m_panel2 );
|
||||
m_notebook->AddPage( m_panel2, _("Default Fields"), false );
|
||||
m_notebook->AddPage( m_panel2, _("Field Name Templates"), false );
|
||||
|
||||
bOptionsSizer->Add( m_notebook, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
<property name="file">dialog_eeschema_options_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">dialog_eeschema_options</property>
|
||||
<property name="namespace"></property>
|
||||
|
@ -4786,11 +4785,11 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="notebookpage" expanded="0">
|
||||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Default Fields</property>
|
||||
<property name="label">Field Name Templates</property>
|
||||
<property name="select">0</property>
|
||||
<object class="wxPanel" expanded="0">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -4864,16 +4863,16 @@
|
|||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer6</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer11</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
|
@ -4905,11 +4904,11 @@
|
|||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="col_label_size">30</property>
|
||||
<property name="col_label_values">"Name" "Default Value" "Visible" "Name" ""</property>
|
||||
<property name="col_label_size">22</property>
|
||||
<property name="col_label_values">"Name" "Visible"</property>
|
||||
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
|
||||
<property name="cols">3</property>
|
||||
<property name="column_sizes">150,150,75</property>
|
||||
<property name="cols">2</property>
|
||||
<property name="column_sizes">300,75</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Apr 19 2018)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
|
|
@ -488,21 +488,6 @@ public:
|
|||
}
|
||||
|
||||
|
||||
bool isModifiedDefaultField( std::pair<wxString, wxString> aFieldData )
|
||||
{
|
||||
wxString name = aFieldData.first;
|
||||
wxString value = aFieldData.second;
|
||||
|
||||
for( auto defaultField : m_frame->GetTemplateFieldNames() )
|
||||
{
|
||||
if( name == defaultField.m_Name && value != defaultField.m_Value )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void ApplyData()
|
||||
{
|
||||
for( unsigned i = 0; i < m_componentRefs.GetCount(); ++i )
|
||||
|
@ -520,7 +505,7 @@ public:
|
|||
wxString srcValue = srcData.second;
|
||||
SCH_FIELD* destField = comp->FindField( srcName );
|
||||
|
||||
if( !destField && ( !srcValue.IsEmpty() || isModifiedDefaultField( srcData ) ) )
|
||||
if( !destField && !srcValue.IsEmpty() )
|
||||
destField = comp->AddField( SCH_FIELD( wxPoint( 0, 0 ), -1, comp, srcName ) );
|
||||
|
||||
if( destField )
|
||||
|
|
|
@ -160,17 +160,12 @@ void NETLIST_EXPORTER_GENERIC::addComponentFields( XNODE* xcomp, SCH_COMPONENT*
|
|||
for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp->GetFieldCount(); ++fldNdx )
|
||||
{
|
||||
SCH_FIELD* f = comp->GetField( fldNdx );
|
||||
|
||||
if( f->GetText().size() )
|
||||
fields.f[ f->GetName() ] = f->GetText();
|
||||
}
|
||||
}
|
||||
|
||||
// Add in non-empty default fields which have not been explicitly defined
|
||||
for( auto defaultField : m_frame->GetTemplateFieldNames() )
|
||||
{
|
||||
if( defaultField.m_Value.size() && fields.f.count( defaultField.m_Name ) == 0 )
|
||||
fields.f[ defaultField.m_Name ] = defaultField.m_Value;
|
||||
}
|
||||
|
||||
// Do not output field values blank in netlist:
|
||||
if( fields.value.size() )
|
||||
xcomp->AddChild( node( "value", fields.value ) );
|
||||
|
|
|
@ -902,8 +902,7 @@ SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
|
|||
}
|
||||
|
||||
|
||||
wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame,
|
||||
bool aIncludeDefaultFields ) const
|
||||
wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const
|
||||
{
|
||||
for( unsigned int ii = 0; ii < m_Fields.size(); ii++ )
|
||||
{
|
||||
|
@ -911,13 +910,6 @@ wxString SCH_COMPONENT::GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME
|
|||
return m_Fields[ii].GetText();
|
||||
}
|
||||
|
||||
if( aIncludeDefaultFields )
|
||||
{
|
||||
for( auto defaultField : aFrame->GetTemplateFieldNames() )
|
||||
if( aFieldName == defaultField.m_Name )
|
||||
return defaultField.m_Value;
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,11 +331,8 @@ public:
|
|||
* Search for a field named \a aFieldName and returns text associated with this field.
|
||||
*
|
||||
* @param aFieldName is the name of the field
|
||||
* @param aIncludeDefaultFields is used to search the default library symbol fields in the
|
||||
* search.
|
||||
*/
|
||||
wxString GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame,
|
||||
bool aIncludeDefaultFields = true ) const;
|
||||
wxString GetFieldText( const wxString& aFieldName, SCH_EDIT_FRAME* aFrame ) const;
|
||||
|
||||
/**
|
||||
* Populates a std::vector with SCH_FIELDs.
|
||||
|
|
Loading…
Reference in New Issue