Meet user expectations on life-cycle of symbol fields.

In other words, support empty fields.

Also adds deleting fields to Symbol Fields Table.

Fixes https://gitlab.com/kicad/code/kicad/issues/8999
This commit is contained in:
Jeff Young 2022-04-12 21:13:26 +01:00
parent 85f6ff48e7
commit 184b67098f
6 changed files with 169 additions and 49 deletions

View File

@ -45,7 +45,7 @@
#include <wx/textdlg.h> #include <wx/textdlg.h>
#include "dialog_symbol_fields_table.h" #include "dialog_symbol_fields_table.h"
#include "eda_list_dialog.h"
#define DISPLAY_NAME_COLUMN 0 #define DISPLAY_NAME_COLUMN 0
#define SHOW_FIELD_COLUMN 1 #define SHOW_FIELD_COLUMN 1
@ -223,6 +223,19 @@ public:
} }
} }
void RemoveColumn( int aCol )
{
wxString fieldName = m_fieldNames[ aCol ];
m_fieldNames.erase( m_fieldNames.begin() + aCol );
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
{
SCH_SYMBOL* symbol = m_symbolsList[ i ].GetSymbol();
m_dataStore[ symbol->m_Uuid ].erase( fieldName );
}
}
int GetNumberRows() override { return m_rows.size(); } int GetNumberRows() override { return m_rows.size(); }
// Columns are fieldNames + quantity column // Columns are fieldNames + quantity column
@ -282,7 +295,7 @@ public:
std::vector<SCH_REFERENCE> references; std::vector<SCH_REFERENCE> references;
wxString fieldValue; wxString fieldValue;
for( const auto& ref : group.m_Refs ) for( const SCH_REFERENCE& ref : group.m_Refs )
{ {
if( aCol == REFERENCE_FIELD || aCol == QUANTITY_COLUMN ) if( aCol == REFERENCE_FIELD || aCol == QUANTITY_COLUMN )
{ {
@ -348,7 +361,7 @@ public:
DATA_MODEL_ROW& rowGroup = m_rows[ aRow ]; DATA_MODEL_ROW& rowGroup = m_rows[ aRow ];
wxString fieldName = m_fieldNames[ aCol ]; wxString fieldName = m_fieldNames[ aCol ];
for( const auto& ref : rowGroup.m_Refs ) for( const SCH_REFERENCE& ref : rowGroup.m_Refs )
m_dataStore[ ref.GetSymbol()->m_Uuid ][ fieldName ] = aValue; m_dataStore[ ref.GetSymbol()->m_Uuid ][ fieldName ] = aValue;
m_edited = true; m_edited = true;
@ -611,21 +624,20 @@ public:
for( const std::pair<wxString, wxString> srcData : fieldStore ) for( const std::pair<wxString, wxString> srcData : fieldStore )
{ {
if( srcData.first == _( "Qty" ) )
continue;
const wxString& srcName = srcData.first; const wxString& srcName = srcData.first;
const wxString& srcValue = srcData.second; const wxString& srcValue = srcData.second;
SCH_FIELD* destField = symbol.FindField( srcName ); SCH_FIELD* destField = symbol.FindField( srcName );
if( !destField && !srcValue.IsEmpty() ) if( !destField )
{ {
const VECTOR2I symbolPos = symbol.GetPosition(); const VECTOR2I symbolPos = symbol.GetPosition();
destField = symbol.AddField( SCH_FIELD( symbolPos, -1, &symbol, srcName ) ); destField = symbol.AddField( SCH_FIELD( symbolPos, -1, &symbol, srcName ) );
} }
if( !destField ) if( destField->GetId() == REFERENCE_FIELD )
{
symbol.RemoveField( srcName );
}
else if( destField->GetId() == REFERENCE_FIELD )
{ {
// Reference is not editable // Reference is not editable
} }
@ -644,6 +656,12 @@ public:
destField->SetText( srcValue ); destField->SetText( srcValue );
} }
} }
for( int ii = symbol.GetFields().size() - 1; ii >= MANDATORY_FIELDS; ii-- )
{
if( fieldStore.count( symbol.GetFields()[ii].GetName() ) == 0 )
symbol.GetFields().erase( symbol.GetFields().begin() + ii );
}
} }
m_edited = false; m_edited = false;
@ -960,7 +978,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
} }
// Force References to always be shown // Force References to always be shown
auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
wxCHECK( cfg, /*void*/ ); wxCHECK( cfg, /*void*/ );
cfg->m_FieldEditorPanel.fields_show["Reference"] = true; cfg->m_FieldEditorPanel.fields_show["Reference"] = true;
@ -986,7 +1004,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
void DIALOG_SYMBOL_FIELDS_TABLE::OnAddField( wxCommandEvent& event ) void DIALOG_SYMBOL_FIELDS_TABLE::OnAddField( wxCommandEvent& event )
{ {
// quantities column will become new field column, so it needs to be reset // quantities column will become new field column, so it needs to be reset
auto attr = new wxGridCellAttr; wxGridCellAttr* attr = new wxGridCellAttr;
m_grid->SetColAttr( m_dataModel->GetColsCount() - 1, attr ); m_grid->SetColAttr( m_dataModel->GetColsCount() - 1, attr );
m_grid->SetColFormatCustom( m_dataModel->GetColsCount() - 1, wxGRID_VALUE_STRING ); m_grid->SetColFormatCustom( m_dataModel->GetColsCount() - 1, wxGRID_VALUE_STRING );
@ -1015,7 +1033,7 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnAddField( wxCommandEvent& event )
std::string key( fieldName.ToUTF8() ); std::string key( fieldName.ToUTF8() );
auto cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
cfg->m_FieldEditorPanel.fields_show[key] = true; cfg->m_FieldEditorPanel.fields_show[key] = true;
AddField( fieldName, fieldName, true, false ); AddField( fieldName, fieldName, true, false );
@ -1033,6 +1051,55 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnAddField( wxCommandEvent& event )
} }
void DIALOG_SYMBOL_FIELDS_TABLE::OnRemoveField( wxCommandEvent& event )
{
wxArrayString headers;
std::vector<wxArrayString> fieldNames;
int col = -1;
headers.Add( _( "User Fields" ) );
for( int ii = MANDATORY_FIELDS; ii < m_fieldsCtrl->GetItemCount(); ++ii )
{
wxArrayString fieldName;
fieldName.Add( m_fieldsCtrl->GetTextValue( ii, 0 ) );
fieldNames.emplace_back( fieldName );
}
EDA_LIST_DIALOG dlg( this, _( "Delete Field" ), headers, fieldNames, wxEmptyString );
dlg.SetListLabel( _( "Select field:" ) );
if( dlg.ShowModal() == wxID_OK )
{
wxString fieldName = dlg.GetTextSelection();
for( int ii = 0; ii < m_dataModel->GetNumberCols(); ++ii )
{
if( fieldName == m_dataModel->GetColLabelValue( ii ) )
col = ii;
}
}
if( col >= 0 )
{
m_fieldsCtrl->DeleteItem( col );
m_dataModel->RemoveColumn( col );
wxGridTableMessage msg( m_dataModel, wxGRIDTABLE_NOTIFY_COLS_DELETED,
m_fieldsCtrl->GetItemCount(), 1 );
m_grid->ProcessTableMessage( msg );
}
// set up attributes on the new quantities column
wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetReadOnly();
m_grid->SetColAttr( m_dataModel->GetColsCount() - 1, attr );
m_grid->SetColFormatNumber( m_dataModel->GetColsCount() - 1 );
m_grid->SetColSize( m_dataModel->GetColsCount() - 1, 50 );
}
void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event ) void DIALOG_SYMBOL_FIELDS_TABLE::OnColumnItemToggled( wxDataViewEvent& event )
{ {
EESCHEMA_SETTINGS* cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ); EESCHEMA_SETTINGS* cfg = static_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );

View File

@ -64,6 +64,7 @@ private:
void OnTableColSize( wxGridSizeEvent& event ) override; void OnTableColSize( wxGridSizeEvent& event ) override;
void OnSizeFieldList( wxSizeEvent& event ) override; void OnSizeFieldList( wxSizeEvent& event ) override;
void OnAddField( wxCommandEvent& event ) override; void OnAddField( wxCommandEvent& event ) override;
void OnRemoveField( wxCommandEvent& event ) override;
void OnSaveAndContinue( wxCommandEvent& aEvent ) override; void OnSaveAndContinue( wxCommandEvent& aEvent ) override;
void OnCancel( wxCommandEvent& event ) override; void OnCancel( wxCommandEvent& event ) override;
void OnClose( wxCloseEvent& event ) override; void OnClose( wxCloseEvent& event ) override;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -32,7 +32,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
m_groupSymbolsBox->SetValue(true); m_groupSymbolsBox->SetValue(true);
m_groupSymbolsBox->SetToolTip( _("Group symbols together based on common properties") ); m_groupSymbolsBox->SetToolTip( _("Group symbols together based on common properties") );
bGroupSizer->Add( m_groupSymbolsBox, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); bGroupSizer->Add( m_groupSymbolsBox, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
bGroupSizer->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 ); bGroupSizer->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 10 );
@ -53,6 +53,9 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
m_addFieldButton = new wxButton( m_leftPanel, wxID_ANY, _("Add Field..."), wxDefaultPosition, wxDefaultSize, 0 ); m_addFieldButton = new wxButton( m_leftPanel, wxID_ANY, _("Add Field..."), wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( m_addFieldButton, 0, wxALL|wxEXPAND, 5 ); bLeftSizer->Add( m_addFieldButton, 0, wxALL|wxEXPAND, 5 );
m_removeFieldButton = new wxButton( m_leftPanel, wxID_ANY, _("Remove Field..."), wxDefaultPosition, wxDefaultSize, 0 );
bLeftSizer->Add( m_removeFieldButton, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_leftPanel->SetSizer( bLeftSizer ); m_leftPanel->SetSizer( bLeftSizer );
m_leftPanel->Layout(); m_leftPanel->Layout();
@ -112,7 +115,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize(); m_sdbSizer->Realize();
bButtonsSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT, 5 ); bButtonsSizer->Add( m_sdbSizer, 0, wxBOTTOM|wxLEFT, 5 );
bMainSizer->Add( bButtonsSizer, 0, wxEXPAND, 5 ); bMainSizer->Add( bButtonsSizer, 0, wxEXPAND, 5 );
@ -131,6 +134,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* pare
m_fieldsCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this ); m_fieldsCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this );
m_fieldsCtrl->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this ); m_fieldsCtrl->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this );
m_addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this ); m_addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this );
m_removeFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRemoveField ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this ); m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this ); m_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this ); m_grid->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this );
@ -149,6 +153,7 @@ DIALOG_SYMBOL_FIELDS_TABLE_BASE::~DIALOG_SYMBOL_FIELDS_TABLE_BASE()
m_fieldsCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this ); m_fieldsCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnColumnItemToggled ), NULL, this );
m_fieldsCtrl->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this ); m_fieldsCtrl->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnSizeFieldList ), NULL, this );
m_addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this ); m_addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnAddField ), NULL, this );
m_removeFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnRemoveField ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this ); m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableValueChanged ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this ); m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this ); m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( DIALOG_SYMBOL_FIELDS_TABLE_BASE::OnTableCellClick ), NULL, this );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project> <wxFormBuilder_Project>
<FileVersion major="1" minor="16" /> <FileVersion major="1" minor="15" />
<object class="Project" expanded="1"> <object class="Project" expanded="1">
<property name="class_decoration"></property> <property name="class_decoration"></property>
<property name="code_generation">C++</property> <property name="code_generation">C++</property>
@ -14,7 +14,6 @@
<property name="file">dialog_symbol_fields_table_base</property> <property name="file">dialog_symbol_fields_table_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property> <property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">dialog_symbol_fields_table_base</property> <property name="name">dialog_symbol_fields_table_base</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property> <property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="ui_table">UI</property> <property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
@ -52,7 +50,6 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Symbol Fields Table</property> <property name="title">Symbol Fields Table</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
@ -191,7 +188,7 @@
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT</property> <property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="0"> <object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -277,7 +274,6 @@
<property name="aui_name"></property> <property name="aui_name"></property>
<property name="aui_position"></property> <property name="aui_position"></property>
<property name="aui_row"></property> <property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="bitmap"></property> <property name="bitmap"></property>
@ -382,7 +378,6 @@
<property name="aui_name"></property> <property name="aui_name"></property>
<property name="aui_position"></property> <property name="aui_position"></property>
<property name="aui_row"></property> <property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="bitmap"></property> <property name="bitmap"></property>
@ -443,6 +438,79 @@
<event name="OnButtonClick">OnAddField</event> <event name="OnButtonClick">OnAddField</event>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Remove Field...</property>
<property name="margins"></property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_removeFieldButton</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRemoveField</event>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>
@ -633,7 +701,6 @@
<property name="aui_name"></property> <property name="aui_name"></property>
<property name="aui_position"></property> <property name="aui_position"></property>
<property name="aui_row"></property> <property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg"></property>
<property name="bitmap"></property> <property name="bitmap"></property>
@ -696,7 +763,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT</property> <property name="flag">wxBOTTOM|wxLEFT</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1"> <object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property> <property name="Apply">0</property>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -49,6 +49,7 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
wxBitmapButton* m_bRefresh; wxBitmapButton* m_bRefresh;
wxDataViewListCtrl* m_fieldsCtrl; wxDataViewListCtrl* m_fieldsCtrl;
wxButton* m_addFieldButton; wxButton* m_addFieldButton;
wxButton* m_removeFieldButton;
wxPanel* m_rightPanel; wxPanel* m_rightPanel;
WX_GRID* m_grid; WX_GRID* m_grid;
wxButton* m_buttonApply; wxButton* m_buttonApply;
@ -56,13 +57,14 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; wxButton* m_sdbSizerCancel;
// Virtual event handlers, override them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnGroupSymbolsToggled( wxCommandEvent& event ) { event.Skip(); } virtual void OnGroupSymbolsToggled( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegroupSymbols( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegroupSymbols( wxCommandEvent& event ) { event.Skip(); }
virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); } virtual void OnColumnItemToggled( wxDataViewEvent& event ) { event.Skip(); }
virtual void OnSizeFieldList( wxSizeEvent& event ) { event.Skip(); } virtual void OnSizeFieldList( wxSizeEvent& event ) { event.Skip(); }
virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddField( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRemoveField( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTableValueChanged( wxGridEvent& event ) { event.Skip(); } virtual void OnTableValueChanged( wxGridEvent& event ) { event.Skip(); }
virtual void OnTableCellClick( wxGridEvent& event ) { event.Skip(); } virtual void OnTableCellClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnTableItemContextMenu( wxGridEvent& event ) { event.Skip(); } virtual void OnTableItemContextMenu( wxGridEvent& event ) { event.Skip(); }
@ -74,7 +76,6 @@ class DIALOG_SYMBOL_FIELDS_TABLE_BASE : public DIALOG_SHIM
public: public:
DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Fields Table"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); DIALOG_SYMBOL_FIELDS_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Fields Table"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
~DIALOG_SYMBOL_FIELDS_TABLE_BASE(); ~DIALOG_SYMBOL_FIELDS_TABLE_BASE();
}; };

View File

@ -677,33 +677,12 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
if( entry && entry->IsPower() ) if( entry && entry->IsPower() )
m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() ); m_fields->at( VALUE_FIELD ).SetText( m_symbol->GetLibId().GetLibItemName() );
// Push all fields to the symbol -except- for those which are TEMPLATE_FIELDNAMES
// with empty values.
SCH_FIELDS& fields = m_symbol->GetFields(); SCH_FIELDS& fields = m_symbol->GetFields();
fields.clear(); fields.clear();
for( size_t i = 0; i < m_fields->size(); ++i ) for( size_t i = 0; i < m_fields->size(); ++i )
{ fields.push_back( m_fields->at( i ) );
SCH_FIELD& field = m_fields->at( i );
bool emptyTemplateField = false;
if( i >= MANDATORY_FIELDS )
{
for( const TEMPLATE_FIELDNAME& fieldname :
schematic.Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
{
if( field.GetName() == fieldname.m_Name && field.GetText().IsEmpty() )
{
emptyTemplateField = true;
break;
}
}
}
if( !emptyTemplateField )
fields.push_back( field );
}
// Reference has a specific initialization, depending on the current active sheet // Reference has a specific initialization, depending on the current active sheet
// because for a given symbol, in a complex hierarchy, there are more than one // because for a given symbol, in a complex hierarchy, there are more than one