diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 1c8035b1e4..c25f950c97 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -26,8 +26,8 @@ set( EESCHEMA_DLGS dialogs/dialog_bom.cpp dialogs/dialog_bom_base.cpp dialogs/dialog_bom_cfg_keywords.cpp - dialogs/dialog_bom_editor.cpp - dialogs/dialog_bom_editor_base.cpp + dialogs/dialog_fields_editor_global.cpp + dialogs/dialog_fields_editor_global_base.cpp dialogs/dialog_choose_component.cpp dialogs/dialog_edit_component_in_lib.cpp dialogs/dialog_edit_component_in_lib_base.cpp @@ -99,8 +99,6 @@ set( EESCHEMA_SRCS backanno.cpp block.cpp block_libedit.cpp - bom_table_column.cpp - bom_table_model.cpp bus-wire-junction.cpp busentry.cpp class_libentry.cpp @@ -122,6 +120,8 @@ set( EESCHEMA_SRCS eeschema_config.cpp erc.cpp events_called_functions_for_edit.cpp + fields_editor_table_column.cpp + fields_editor_table_model.cpp files-io.cpp find.cpp generate_alias_info.cpp diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index 7dd8b6a01d..a5b679eaec 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -35,25 +35,23 @@ #include #include -#include "dialog_bom_editor.h" -#include - -/* BOM Table Colours */ +#include "dialog_fields_editor_global.h" +#include -// Create and show BOM editor +// Create and show fields editor void InvokeDialogCreateBOMEditor( SCH_EDIT_FRAME* aCaller ) { - DIALOG_BOM_EDITOR dlg( aCaller ); + DIALOG_FIELDS_EDITOR_GLOBAL dlg( aCaller ); dlg.ShowQuasiModal(); } -DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) : - DIALOG_BOM_EDITOR_BASE( parent ), +DIALOG_FIELDS_EDITOR_GLOBAL::DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ) : + DIALOG_FIELDS_EDITOR_GLOBAL_BASE( parent ), m_parent( parent ) { - m_bom = BOM_TABLE_MODEL::Create(); + m_bom = FIELDS_EDITOR_TABLE_MODEL::Create(); auto nameColumn = m_columnListCtrl->AppendTextColumn( _( "Field" ) ); @@ -104,24 +102,24 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) : } -DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR() +DIALOG_FIELDS_EDITOR_GLOBAL::~DIALOG_FIELDS_EDITOR_GLOBAL() { // Nothing to do. } -void DIALOG_BOM_EDITOR::OnCloseButton( wxCommandEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnCloseButton( wxCommandEvent& event ) { - // DIALOG_BOM_EDITOR::OnDialogClosed() will be called, + // DIALOG_FIELDS_EDITOR_GLOBAL::OnDialogClosed() will be called, // when closing this dialog. // The default wxID_CANCEL handler is not suitable for us, // because it calls DIALOG_SHIM::EndQuasiModal() without calling - // DIALOG_BOM_EDITOR::OnDialogClosed() + // DIALOG_FIELDS_EDITOR_GLOBAL::OnDialogClosed() Close(); } -bool DIALOG_BOM_EDITOR::CanCloseDialog() +bool DIALOG_FIELDS_EDITOR_GLOBAL::CanCloseDialog() { if( !m_bom->HaveFieldsChanged() ) return true; @@ -145,7 +143,7 @@ bool DIALOG_BOM_EDITOR::CanCloseDialog() } -void DIALOG_BOM_EDITOR::OnDialogClosed( wxCloseEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnDialogClosed( wxCloseEvent& event ) { if( !CanCloseDialog() ) { @@ -171,7 +169,7 @@ typedef struct } SheetUndoList; -void DIALOG_BOM_EDITOR::ApplyAllChanges() +void DIALOG_FIELDS_EDITOR_GLOBAL::ApplyAllChanges() { if( !m_bom->HaveFieldsChanged() ) return; @@ -253,7 +251,7 @@ void DIALOG_BOM_EDITOR::ApplyAllChanges() } -void DIALOG_BOM_EDITOR::UpdateTitle() +void DIALOG_FIELDS_EDITOR_GLOBAL::UpdateTitle() { wxString title; @@ -281,7 +279,7 @@ void DIALOG_BOM_EDITOR::UpdateTitle() } -void DIALOG_BOM_EDITOR::LoadComponents() +void DIALOG_FIELDS_EDITOR_GLOBAL::LoadComponents() { if( !m_parent ) return; @@ -297,7 +295,7 @@ void DIALOG_BOM_EDITOR::LoadComponents() } -void DIALOG_BOM_EDITOR::LoadColumnNames() +void DIALOG_FIELDS_EDITOR_GLOBAL::LoadColumnNames() { m_columnListCtrl->DeleteAllItems(); @@ -319,14 +317,14 @@ void DIALOG_BOM_EDITOR::LoadColumnNames() } -void DIALOG_BOM_EDITOR::ReloadColumns() +void DIALOG_FIELDS_EDITOR_GLOBAL::ReloadColumns() { m_bom->AttachTo( m_bomView ); UpdateTitle(); } -void DIALOG_BOM_EDITOR::OnColumnItemToggled( wxDataViewEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnColumnItemToggled( wxDataViewEvent& event ) { wxDataViewItem item = event.GetItem(); @@ -336,7 +334,7 @@ void DIALOG_BOM_EDITOR::OnColumnItemToggled( wxDataViewEvent& event ) if( row == wxNOT_FOUND || row < 0 || row >= (int) m_bom->ColumnCount() ) return; - BOM_COLUMN* bomColumn = m_bom->ColumnList.GetColumnByIndex( row ); + FIELDS_EDITOR_COLUMN* bomColumn = m_bom->ColumnList.GetColumnByIndex( row ); if( nullptr == bomColumn ) return; @@ -370,7 +368,7 @@ void DIALOG_BOM_EDITOR::OnColumnItemToggled( wxDataViewEvent& event ) } -void DIALOG_BOM_EDITOR::OnGroupComponentsToggled( wxCommandEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnGroupComponentsToggled( wxCommandEvent& event ) { bool group = m_groupComponentsBox->GetValue(); @@ -381,7 +379,7 @@ void DIALOG_BOM_EDITOR::OnGroupComponentsToggled( wxCommandEvent& event ) } -void DIALOG_BOM_EDITOR::OnUpdateUI( wxUpdateUIEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnUpdateUI( wxUpdateUIEvent& event ) { m_regroupComponentsButton->Enable( m_bom->GetColumnGrouping() ); @@ -394,27 +392,27 @@ void DIALOG_BOM_EDITOR::OnUpdateUI( wxUpdateUIEvent& event ) } -void DIALOG_BOM_EDITOR::OnTableValueChanged( wxDataViewEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableValueChanged( wxDataViewEvent& event ) { Update(); } -void DIALOG_BOM_EDITOR::OnRegroupComponents( wxCommandEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnRegroupComponents( wxCommandEvent& event ) { m_bom->ReloadTable(); Update(); } -void DIALOG_BOM_EDITOR::OnApplyFieldChanges( wxCommandEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnApplyFieldChanges( wxCommandEvent& event ) { ApplyAllChanges(); Update(); } -void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnRevertFieldChanges( wxCommandEvent& event ) { if( m_bom->HaveFieldsChanged() ) { @@ -427,7 +425,7 @@ void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event ) } -void DIALOG_BOM_EDITOR::OnTableItemActivated( wxDataViewEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableItemActivated( wxDataViewEvent& event ) { /* TODO * - Focus on component selected in SCH_FRAME @@ -437,7 +435,7 @@ void DIALOG_BOM_EDITOR::OnTableItemActivated( wxDataViewEvent& event ) } -void DIALOG_BOM_EDITOR::OnTableItemContextMenu( wxDataViewEvent& event ) +void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableItemContextMenu( wxDataViewEvent& event ) { /* TODO * - Display contect menu diff --git a/eeschema/dialogs/dialog_fields_editor_global.h b/eeschema/dialogs/dialog_fields_editor_global.h index 7ccb98483d..926fdb700f 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.h +++ b/eeschema/dialogs/dialog_fields_editor_global.h @@ -23,12 +23,12 @@ */ /** - * @file eeschema/dialogs/dialog_bom_editor.cpp + * @file eeschema/dialogs/dialog_fields_editor_global.cpp * @brief Dialog box for creating bom and other documents from generic netlist. */ -#ifndef DIALOG_BOM_EDITOR_H -#define DIALOG_BOM_EDITOR_H +#ifndef DIALOG_FIELDS_EDITOR_GLOBAL_H +#define DIALOG_FIELDS_EDITOR_GLOBAL_H #include @@ -37,25 +37,25 @@ #include #include #include -#include +#include #include #include #include -#include +#include -class DIALOG_BOM_EDITOR : public DIALOG_BOM_EDITOR_BASE +class DIALOG_FIELDS_EDITOR_GLOBAL : public DIALOG_FIELDS_EDITOR_GLOBAL_BASE { public: - DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ); - virtual ~DIALOG_BOM_EDITOR(); + DIALOG_FIELDS_EDITOR_GLOBAL( SCH_EDIT_FRAME* parent ); + virtual ~DIALOG_FIELDS_EDITOR_GLOBAL(); private: //! Parent object (Schematic) SCH_EDIT_FRAME* m_parent; - BOM_TABLE_MODEL::MODEL_PTR m_bom; + FIELDS_EDITOR_TABLE_MODEL::MODEL_PTR m_bom; void LoadComponents(); @@ -95,4 +95,4 @@ private: }; -#endif /* DIALOG_BOM_EDITOR_H */ +#endif /* DIALOG_FIELDS_EDITOR_GLOBAL_H */ diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.cpp b/eeschema/dialogs/dialog_fields_editor_global_base.cpp index a1c7bb54f7..056d011e50 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global_base.cpp @@ -1,15 +1,15 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jan 2 2018) +// C++ code generated with wxFormBuilder (version Aug 4 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_bom_editor_base.h" +#include "dialog_fields_editor_global_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -24,7 +24,7 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id, bSizer7 = new wxBoxSizer( wxVERTICAL ); m_splitter1 = new wxSplitterWindow( m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D ); - m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_BOM_EDITOR_BASE::m_splitter1OnIdle ), NULL, this ); + m_splitter1->Connect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::m_splitter1OnIdle ), NULL, this ); m_splitter1->SetMinimumPaneSize( 120 ); m_leftPanel = new wxPanel( m_splitter1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); @@ -89,23 +89,23 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id, bSizer7->Fit( m_panel ); bSizer61->Add( m_panel, 1, wxEXPAND | wxALL, 5 ); - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizerButtonsBottom; + bSizerButtonsBottom = new wxBoxSizer( wxHORIZONTAL ); m_applyChangesButton = new wxButton( this, wxID_ANY, _("Apply Changes"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer71->Add( m_applyChangesButton, 0, wxALL, 5 ); + bSizerButtonsBottom->Add( m_applyChangesButton, 0, wxALL, 5 ); m_revertChangesButton = new wxButton( this, wxID_ANY, _("Revert Changes"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer71->Add( m_revertChangesButton, 0, wxALL, 5 ); + bSizerButtonsBottom->Add( m_revertChangesButton, 0, wxALL, 5 ); - bSizer71->Add( 0, 0, 1, wxEXPAND, 5 ); + bSizerButtonsBottom->Add( 0, 0, 1, wxEXPAND, 5 ); m_closeButton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer71->Add( m_closeButton, 0, wxALL, 5 ); + bSizerButtonsBottom->Add( m_closeButton, 0, wxALL, 5 ); - bSizer61->Add( bSizer71, 0, wxEXPAND, 5 ); + bSizer61->Add( bSizerButtonsBottom, 0, wxEXPAND, 5 ); bHorizontalSizer->Add( bSizer61, 1, wxEXPAND, 5 ); @@ -118,38 +118,38 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id, this->Centre( wxBOTH ); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_BOM_EDITOR_BASE::OnDialogClosed ) ); - this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_BOM_EDITOR_BASE::OnUpdateUI ) ); - m_groupComponentsBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnGroupComponentsToggled ), NULL, this ); - m_regroupComponentsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnRegroupComponents ), NULL, this ); - m_columnListCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnColumnItemToggled ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnBomColumReordered ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnBomColumnSorted ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableItemActivated ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableItemContextMenu ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableValueChanged ), NULL, this ); - m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnSelectionChanged ), NULL, this ); - m_applyChangesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnApplyFieldChanges ), NULL, this ); - m_revertChangesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnRevertFieldChanges ), NULL, this ); - m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnCloseButton ), NULL, this ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnDialogClosed ) ); + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnUpdateUI ) ); + m_groupComponentsBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnGroupComponentsToggled ), NULL, this ); + m_regroupComponentsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRegroupComponents ), NULL, this ); + m_columnListCtrl->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnColumnItemToggled ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnBomColumReordered ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnBomColumnSorted ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemActivated ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableValueChanged ), NULL, this ); + m_bomView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSelectionChanged ), NULL, this ); + m_applyChangesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnApplyFieldChanges ), NULL, this ); + m_revertChangesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRevertFieldChanges ), NULL, this ); + m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCloseButton ), NULL, this ); } -DIALOG_BOM_EDITOR_BASE::~DIALOG_BOM_EDITOR_BASE() +DIALOG_FIELDS_EDITOR_GLOBAL_BASE::~DIALOG_FIELDS_EDITOR_GLOBAL_BASE() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_BOM_EDITOR_BASE::OnDialogClosed ) ); - this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_BOM_EDITOR_BASE::OnUpdateUI ) ); - m_groupComponentsBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnGroupComponentsToggled ), NULL, this ); - m_regroupComponentsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnRegroupComponents ), NULL, this ); - m_columnListCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnColumnItemToggled ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnBomColumReordered ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnBomColumnSorted ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableItemActivated ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableItemContextMenu ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnTableValueChanged ), NULL, this ); - m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_BOM_EDITOR_BASE::OnSelectionChanged ), NULL, this ); - m_applyChangesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnApplyFieldChanges ), NULL, this ); - m_revertChangesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnRevertFieldChanges ), NULL, this ); - m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_BOM_EDITOR_BASE::OnCloseButton ), NULL, this ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnDialogClosed ) ); + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnUpdateUI ) ); + m_groupComponentsBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnGroupComponentsToggled ), NULL, this ); + m_regroupComponentsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRegroupComponents ), NULL, this ); + m_columnListCtrl->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnColumnItemToggled ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnBomColumReordered ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnBomColumnSorted ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemActivated ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableValueChanged ), NULL, this ); + m_bomView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSelectionChanged ), NULL, this ); + m_applyChangesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnApplyFieldChanges ), NULL, this ); + m_revertChangesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnRevertFieldChanges ), NULL, this ); + m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCloseButton ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.fbp b/eeschema/dialogs/dialog_fields_editor_global_base.fbp index ed66d8f03b..9cb289d078 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.fbp +++ b/eeschema/dialogs/dialog_fields_editor_global_base.fbp @@ -11,11 +11,11 @@ res UTF-8 connect - dialog_bom_editor_base + dialog_fields_editor_global_base 1000 none 1 - dialog_bom_editor_base + dialog_fields_editor_global_base . @@ -42,12 +42,12 @@ wxID_ANY - DIALOG_BOM_EDITOR_BASE + DIALOG_FIELDS_EDITOR_GLOBAL_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h - BOM editor + Fields editor @@ -641,8 +641,8 @@ - - + + 1 1 1 @@ -716,7 +716,7 @@ - + bSizer5 wxVERTICAL @@ -803,7 +803,7 @@ 0 - bSizer71 + bSizerButtonsBottom wxHORIZONTAL none diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.h b/eeschema/dialogs/dialog_fields_editor_global_base.h index 7aec08f75d..43d307e314 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.h +++ b/eeschema/dialogs/dialog_fields_editor_global_base.h @@ -1,16 +1,18 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jan 2 2018) +// C++ code generated with wxFormBuilder (version Aug 4 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_BOM_EDITOR_BASE_H__ -#define __DIALOG_BOM_EDITOR_BASE_H__ +#ifndef __DIALOG_FIELDS_EDITOR_GLOBAL_BASE_H__ +#define __DIALOG_FIELDS_EDITOR_GLOBAL_BASE_H__ #include #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include @@ -31,9 +33,9 @@ #define OPT_GROUP_COMPONENTS 1000 /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_BOM_EDITOR_BASE +/// Class DIALOG_FIELDS_EDITOR_GLOBAL_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM +class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM { private: @@ -69,15 +71,15 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM public: - DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); - ~DIALOG_BOM_EDITOR_BASE(); + DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fields editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); + ~DIALOG_FIELDS_EDITOR_GLOBAL_BASE(); void m_splitter1OnIdle( wxIdleEvent& ) { m_splitter1->SetSashPosition( 231 ); - m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_BOM_EDITOR_BASE::m_splitter1OnIdle ), NULL, this ); + m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::m_splitter1OnIdle ), NULL, this ); } }; -#endif //__DIALOG_BOM_EDITOR_BASE_H__ +#endif //__DIALOG_FIELDS_EDITOR_GLOBAL_BASE_H__ diff --git a/eeschema/fields_editor_table_column.cpp b/eeschema/fields_editor_table_column.cpp index 2a602bd8f6..6c50e7deef 100644 --- a/eeschema/fields_editor_table_column.cpp +++ b/eeschema/fields_editor_table_column.cpp @@ -22,28 +22,28 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "bom_table_column.h" +#include "fields_editor_table_column.h" -BOM_COLUMN_LIST::BOM_COLUMN_LIST() : m_nextFieldId( BOM_COL_ID_USER ) +FIELDS_EDITOR_COLUMN_LIST::FIELDS_EDITOR_COLUMN_LIST() : m_nextFieldId( FIELDS_EDITOR_COL_ID_USER ) { } -void BOM_COLUMN_LIST::Clear() +void FIELDS_EDITOR_COLUMN_LIST::Clear() { Columns.clear(); - m_nextFieldId = BOM_COL_ID_USER; + m_nextFieldId = FIELDS_EDITOR_COL_ID_USER; } /** * Return the number of columns * @param aIncludeHidden - If this is false, only visible columns will be included */ -unsigned int BOM_COLUMN_LIST::ColumnCount( bool aIncludeHidden ) const +unsigned int FIELDS_EDITOR_COLUMN_LIST::ColumnCount( bool aIncludeHidden ) const { unsigned int count = 0; - for( BOM_COLUMN* col : Columns ) + for( FIELDS_EDITOR_COLUMN* col : Columns ) { if( col && ( col->IsVisible() || aIncludeHidden ) ) { @@ -57,7 +57,7 @@ unsigned int BOM_COLUMN_LIST::ColumnCount( bool aIncludeHidden ) const /** * Return a column based on its stored position */ -BOM_COLUMN* BOM_COLUMN_LIST::GetColumnByIndex( unsigned int aColId ) +FIELDS_EDITOR_COLUMN* FIELDS_EDITOR_COLUMN_LIST::GetColumnByIndex( unsigned int aColId ) { if( aColId < Columns.size() ) return Columns[aColId]; @@ -68,7 +68,7 @@ BOM_COLUMN* BOM_COLUMN_LIST::GetColumnByIndex( unsigned int aColId ) /** * Return a column based on its unique ID */ -BOM_COLUMN* BOM_COLUMN_LIST::GetColumnById( unsigned int aColId ) +FIELDS_EDITOR_COLUMN* FIELDS_EDITOR_COLUMN_LIST::GetColumnById( unsigned int aColId ) { for( unsigned int ii=0; iiId() == aColId ) return true; @@ -110,7 +110,7 @@ bool BOM_COLUMN_LIST::ContainsColumn( unsigned int aColId ) /** * Test if the list includes a column with the given title */ -bool BOM_COLUMN_LIST::ContainsColumn( const wxString& aColTitle ) +bool FIELDS_EDITOR_COLUMN_LIST::ContainsColumn( const wxString& aColTitle ) { return nullptr != GetColumnByTitle( aColTitle ); } @@ -118,7 +118,7 @@ bool BOM_COLUMN_LIST::ContainsColumn( const wxString& aColTitle ) /** * Add a new column to the list */ -bool BOM_COLUMN_LIST::AddColumn( BOM_COLUMN* aCol ) +bool FIELDS_EDITOR_COLUMN_LIST::AddColumn( FIELDS_EDITOR_COLUMN* aCol ) { if( nullptr == aCol ) return false; @@ -129,7 +129,7 @@ bool BOM_COLUMN_LIST::AddColumn( BOM_COLUMN* aCol ) Columns.push_back( aCol ); // If this is a user field, increment the counter - if( aCol->Id() >= BOM_COL_ID_USER ) + if( aCol->Id() >= FIELDS_EDITOR_COL_ID_USER ) m_nextFieldId++; return true; diff --git a/eeschema/fields_editor_table_column.h b/eeschema/fields_editor_table_column.h index f117adba97..7ba996bab2 100644 --- a/eeschema/fields_editor_table_column.h +++ b/eeschema/fields_editor_table_column.h @@ -22,20 +22,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef EESCHEMA_BOM_TABLE_COLUMN_H_ -#define EESCHEMA_BOM_TABLE_COLUMN_H_ +#ifndef FIELDS_EDITOR_TABLE_COLUMN_H +#define FIELDS_EDITOR_TABLE_COLUMN_H #include #include #include // Default column names (translated) -#define BOM_COL_TITLE_REFERENCE _( "Reference" ) -#define BOM_COL_TITLE_DESCRIPTION _( "Description" ) -#define BOM_COL_TITLE_FOOTPRINT _( "Footprint" ) -#define BOM_COL_TITLE_VALUE _( "Value" ) -#define BOM_COL_TITLE_DATASHEET _( "Datasheet" ) -#define BOM_COL_TITLE_QUANTITY _( "Quantity" ) +#define FIELDS_EDITOR_COL_TITLE_REFERENCE _( "Reference" ) +#define FIELDS_EDITOR_COL_TITLE_DESCRIPTION _( "Description" ) +#define FIELDS_EDITOR_COL_TITLE_FOOTPRINT _( "Footprint" ) +#define FIELDS_EDITOR_COL_TITLE_VALUE _( "Value" ) +#define FIELDS_EDITOR_COL_TITLE_DATASHEET _( "Datasheet" ) +#define FIELDS_EDITOR_COL_TITLE_QUANTITY _( "Quantity" ) /** * Column type enumeration @@ -43,12 +43,12 @@ * in the future the different column 'types' might * be used for something... */ -enum BOM_COLUMN_TYPE +enum FIELDS_EDITOR_COLUMN_TYPE { - BOM_COL_TYPE_KICAD = 0, ///< Default column (editable) - BOM_COL_TYPE_LIBRARY, ///< Default column (non-editable) - BOM_COL_TYPE_GENERATED, ///< Generated column (e.g. Quantity) - BOM_COL_TYPE_USER, ///< User data + FIELDS_EDITOR_COL_TYPE_KICAD = 0, ///< Default column (editable) + FIELDS_EDITOR_COL_TYPE_LIBRARY, ///< Default column (non-editable) + FIELDS_EDITOR_COL_TYPE_GENERATED, ///< Generated column (e.g. Quantity) + FIELDS_EDITOR_COL_TYPE_USER, ///< User data }; @@ -56,33 +56,33 @@ enum BOM_COLUMN_TYPE * Predefined column ID values for default columns. * User columns are assigned IDs of 1000 and above */ -enum BOM_COLUMN_ID +enum FIELDS_EDITOR_COLUMN_ID { // Default component fields - BOM_COL_ID_REFERENCE = 0, - BOM_COL_ID_DESCRIPTION, - BOM_COL_ID_FOOTPRINT, - BOM_COL_ID_VALUE, - BOM_COL_ID_DATASHEET, + FIELDS_EDITOR_COL_ID_REFERENCE = 0, + FIELDS_EDITOR_COL_ID_DESCRIPTION, + FIELDS_EDITOR_COL_ID_FOOTPRINT, + FIELDS_EDITOR_COL_ID_VALUE, + FIELDS_EDITOR_COL_ID_DATASHEET, // Meta-data fields - BOM_COL_ID_QUANTITY = 100, + FIELDS_EDITOR_COL_ID_QUANTITY = 100, // Custom data fields - BOM_COL_ID_USER = 1000, + FIELDS_EDITOR_COL_ID_USER = 1000, }; /** - * BOM_COLUMN class + * FIELDS_EDITOR_COLUMN class * Models a single column in the BOM view * Each column can be used to group components, * and can be hidden from the output BOM */ -class BOM_COLUMN +class FIELDS_EDITOR_COLUMN { protected: unsigned int m_id; ///< Unique column ID - BOM_COLUMN_TYPE m_Type; ///< Column type + FIELDS_EDITOR_COLUMN_TYPE m_Type; ///< Column type wxString m_Title; ///< The column (field) title bool m_Show; ///< Is this column visible? @@ -91,7 +91,7 @@ protected: bool m_sort; ///< Is this column used for sorting? public: - BOM_COLUMN( unsigned int aId, BOM_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false, bool aSort = true ) : + FIELDS_EDITOR_COLUMN( unsigned int aId, FIELDS_EDITOR_COLUMN_TYPE aType, const wxString aTitle, bool aShow, bool aReadOnly = false, bool aSort = true ) : m_id( aId ), m_Type( aType ), m_Title( aTitle.Strip( wxString::both ) ), @@ -102,7 +102,7 @@ public: } unsigned int Id() const { return m_id; } - BOM_COLUMN_TYPE Type() const { return m_Type; } + FIELDS_EDITOR_COLUMN_TYPE Type() const { return m_Type; } wxString Title() const { return m_Title; } bool IsVisible() const { return m_Show; } bool IsReadOnly() const { return m_ReadOnly; } @@ -117,36 +117,36 @@ public: }; /* - * The BOM_COLUMN_LIST class contains information + * The FIELDS_EDITOR_COLUMN_LIST class contains information * on all columns existing in the BOM */ -class BOM_COLUMN_LIST +class FIELDS_EDITOR_COLUMN_LIST { protected: unsigned int m_nextFieldId; public: - std::vector< BOM_COLUMN* > Columns; + std::vector< FIELDS_EDITOR_COLUMN* > Columns; - BOM_COLUMN_LIST(); + FIELDS_EDITOR_COLUMN_LIST(); void Clear(); unsigned int NextFieldId() const { return m_nextFieldId; } unsigned int ColumnCount( bool aIncludeHidden = true ) const; - BOM_COLUMN* GetColumnByIndex( unsigned int aColIndex ); - BOM_COLUMN* GetColumnById( unsigned int aColId ); - BOM_COLUMN* GetColumnByTitle( const wxString& aColTitle ) ; + FIELDS_EDITOR_COLUMN* GetColumnByIndex( unsigned int aColIndex ); + FIELDS_EDITOR_COLUMN* GetColumnById( unsigned int aColId ); + FIELDS_EDITOR_COLUMN* GetColumnByTitle( const wxString& aColTitle ) ; bool ContainsColumn( unsigned int aColId ); bool ContainsColumn( const wxString& aColTitle ); - bool AddColumn( BOM_COLUMN* aCol ); + bool AddColumn( FIELDS_EDITOR_COLUMN* aCol ); }; -#endif /* EESCHEMA_BOM_TABLE_COLUMN_H_ */ +#endif /* FIELDS_EDITOR_TABLE_COLUMN_H */ diff --git a/eeschema/fields_editor_table_model.cpp b/eeschema/fields_editor_table_model.cpp index 5dd6b39207..262ad49f95 100644 --- a/eeschema/fields_editor_table_model.cpp +++ b/eeschema/fields_editor_table_model.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "bom_table_model.h" +#include "fields_editor_table_model.h" // Indicator that multiple values exist in child rows #define ROW_MULT_ITEMS wxString( "<...>" ) @@ -32,18 +32,18 @@ static const wxColor ROW_COLOUR_MULTIPLE_ITEMS( 60, 90, 200 ); /** - * Convert BOM_TABLE_ROW -> wxDataViewItem + * Convert FIELDS_EDITOR_TABLE_ROW -> wxDataViewItem */ -static wxDataViewItem RowToItem( BOM_TABLE_ROW const* aRow ) +static wxDataViewItem RowToItem( FIELDS_EDITOR_TABLE_ROW const* aRow ) { return wxDataViewItem( const_cast( static_cast( aRow ) ) ); } /** - * Convert wxDataViewItem -> BOM_TABEL_ROW + * Convert wxDataViewItem -> FIELDS_EDITOR_TABEL_ROW */ -static BOM_TABLE_ROW const* ItemToRow( wxDataViewItem aItem ) +static FIELDS_EDITOR_TABLE_ROW const* ItemToRow( wxDataViewItem aItem ) { if( !aItem.IsOk() ) { @@ -51,19 +51,19 @@ static BOM_TABLE_ROW const* ItemToRow( wxDataViewItem aItem ) } else { - return static_cast( aItem.GetID() ); + return static_cast( aItem.GetID() ); } } -BOM_FIELD_VALUES::BOM_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate ) : +FIELDS_EDITOR_FIELD_VALUES::FIELDS_EDITOR_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate ) : m_refDes( aRefDes ), m_templateValues( aTemplate ) { } -bool BOM_FIELD_VALUES::GetFieldValue( unsigned int aFieldId, wxString& aValue ) const +bool FIELDS_EDITOR_FIELD_VALUES::GetFieldValue( unsigned int aFieldId, wxString& aValue ) const { auto search = m_currentValues.find( aFieldId ); @@ -76,7 +76,7 @@ bool BOM_FIELD_VALUES::GetFieldValue( unsigned int aFieldId, wxString& aValue ) } -bool BOM_FIELD_VALUES::GetBackupValue( unsigned int aFieldId, wxString& aValue ) const +bool FIELDS_EDITOR_FIELD_VALUES::GetBackupValue( unsigned int aFieldId, wxString& aValue ) const { auto search = m_backupValues.find( aFieldId ); @@ -89,7 +89,7 @@ bool BOM_FIELD_VALUES::GetBackupValue( unsigned int aFieldId, wxString& aValue ) } -bool BOM_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const +bool FIELDS_EDITOR_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue ) const { if( !m_templateValues ) return false; @@ -105,7 +105,7 @@ bool BOM_FIELD_VALUES::GetTemplateValue( unsigned int aFieldId, wxString& aValue } -void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, const wxString& aValue, +void FIELDS_EDITOR_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, const wxString& aValue, bool aOverwrite ) { if( aOverwrite || m_currentValues.count( aFieldId ) == 0 || @@ -116,7 +116,7 @@ void BOM_FIELD_VALUES::SetFieldValue( unsigned int aFieldId, const wxString& aVa } -bool BOM_FIELD_VALUES::HasValueChanged( unsigned int aFieldId) const +bool FIELDS_EDITOR_FIELD_VALUES::HasValueChanged( unsigned int aFieldId) const { wxString currentValue, backupValue; @@ -127,7 +127,7 @@ bool BOM_FIELD_VALUES::HasValueChanged( unsigned int aFieldId) const } -void BOM_FIELD_VALUES::RevertChanges( unsigned int aFieldId ) +void FIELDS_EDITOR_FIELD_VALUES::RevertChanges( unsigned int aFieldId ) { wxString backupValue; @@ -136,7 +136,7 @@ void BOM_FIELD_VALUES::RevertChanges( unsigned int aFieldId ) SetFieldValue( aFieldId, backupValue, true ); } -void BOM_FIELD_VALUES::SetBackupPoint() +void FIELDS_EDITOR_FIELD_VALUES::SetBackupPoint() { for( auto it = m_currentValues.begin(); it != m_currentValues.end(); ++it ) { @@ -145,7 +145,7 @@ void BOM_FIELD_VALUES::SetBackupPoint() } -BOM_TABLE_ROW::BOM_TABLE_ROW() : m_columnList( nullptr ) +FIELDS_EDITOR_TABLE_ROW::FIELDS_EDITOR_TABLE_ROW() : m_columnList( nullptr ) { } @@ -154,7 +154,7 @@ BOM_TABLE_ROW::BOM_TABLE_ROW() : m_columnList( nullptr ) * Update cell attributes based on parameters of the cell * Default implementation highlights cells that have been altered */ -bool BOM_TABLE_ROW::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const +bool FIELDS_EDITOR_TABLE_ROW::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const { auto field = m_columnList->GetColumnById( aFieldId ); @@ -170,7 +170,7 @@ bool BOM_TABLE_ROW::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) } -bool BOM_TABLE_ROW::HasChanged() const +bool FIELDS_EDITOR_TABLE_ROW::HasChanged() const { if( !m_columnList ) return false; @@ -190,13 +190,13 @@ bool BOM_TABLE_ROW::HasChanged() const /** * Create a new group (which contains one or more components) */ -BOM_TABLE_GROUP::BOM_TABLE_GROUP( BOM_COLUMN_LIST* aColumnList ) +FIELDS_EDITOR_TABLE_GROUP::FIELDS_EDITOR_TABLE_GROUP( FIELDS_EDITOR_COLUMN_LIST* aColumnList ) { m_columnList = aColumnList; } -bool BOM_TABLE_GROUP::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const +bool FIELDS_EDITOR_TABLE_GROUP::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const { if( GetFieldValue( aFieldId ).Cmp( ROW_MULT_ITEMS ) == 0 ) { @@ -205,7 +205,7 @@ bool BOM_TABLE_GROUP::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr return true; } - return BOM_TABLE_ROW::GetAttr( aFieldId, aAttr ); + return FIELDS_EDITOR_TABLE_ROW::GetAttr( aFieldId, aAttr ); } @@ -213,7 +213,7 @@ bool BOM_TABLE_GROUP::GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr * Return the value associated with a given field in the group. * Some fields require special attention. */ -wxString BOM_TABLE_GROUP::GetFieldValue( unsigned int aFieldId ) const +wxString FIELDS_EDITOR_TABLE_GROUP::GetFieldValue( unsigned int aFieldId ) const { wxString value; @@ -221,12 +221,12 @@ wxString BOM_TABLE_GROUP::GetFieldValue( unsigned int aFieldId ) const switch( aFieldId ) { // QUANTITY returns the size of the group - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_QUANTITY: value = wxString::Format( "%u", (unsigned int) GroupSize() ); break; // REFERENCE field returns consolidated list of references - case BOM_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_REFERENCE: value = wxJoin( GetReferences(), ' ' ); break; @@ -267,7 +267,7 @@ wxString BOM_TABLE_GROUP::GetFieldValue( unsigned int aFieldId ) const * Set the value of a field in a group * The new value is pushed to all components that are children of this group */ -bool BOM_TABLE_GROUP::SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite ) +bool FIELDS_EDITOR_TABLE_GROUP::SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite ) { bool result = false; @@ -289,7 +289,7 @@ bool BOM_TABLE_GROUP::SetFieldValue( unsigned int aFieldId, const wxString aValu * @param aField - The field to test * @param aComponent - The component being tested */ -bool BOM_TABLE_GROUP::TestField( BOM_COLUMN* aField, BOM_TABLE_COMPONENT* aComponent ) const +bool FIELDS_EDITOR_TABLE_GROUP::TestField( FIELDS_EDITOR_COLUMN* aField, FIELDS_EDITOR_TABLE_COMPONENT* aComponent ) const { if( !aField || !aComponent ) return false; @@ -305,11 +305,11 @@ bool BOM_TABLE_GROUP::TestField( BOM_COLUMN* aField, BOM_TABLE_COMPONENT* aCompo switch( aField->Id() ) { // These fields should NOT be compared (return True) - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_QUANTITY: return true; // Reference matching is done only on prefix - case BOM_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_REFERENCE: componentValue = aComponent->GetPrefix(); comparisonValue = Components[0]->GetPrefix(); break; @@ -331,7 +331,7 @@ bool BOM_TABLE_GROUP::TestField( BOM_COLUMN* aField, BOM_TABLE_COMPONENT* aCompo * It is assumed at this stage that the component is a good match for the group. * @param aComponent is the new component to add */ -bool BOM_TABLE_GROUP::AddComponent( BOM_TABLE_COMPONENT* aComponent ) +bool FIELDS_EDITOR_TABLE_GROUP::AddComponent( FIELDS_EDITOR_TABLE_COMPONENT* aComponent ) { if( !aComponent ) return false; @@ -372,7 +372,7 @@ bool BOM_TABLE_GROUP::AddComponent( BOM_TABLE_COMPONENT* aComponent ) /** * Adds each child row to the supplied list, and returns the total child count */ -unsigned int BOM_TABLE_GROUP::GetChildren( wxDataViewItemArray& aChildren ) const +unsigned int FIELDS_EDITOR_TABLE_GROUP::GetChildren( wxDataViewItemArray& aChildren ) const { // Show drop-down for child components for( auto& row : Components ) @@ -392,7 +392,7 @@ unsigned int BOM_TABLE_GROUP::GetChildren( wxDataViewItemArray& aChildren ) cons * @param aField is the field to test * @return true if any children have changed else false */ -bool BOM_TABLE_GROUP::HasValueChanged( BOM_COLUMN* aField ) const +bool FIELDS_EDITOR_TABLE_GROUP::HasValueChanged( FIELDS_EDITOR_COLUMN* aField ) const { bool changed = false; @@ -425,7 +425,7 @@ bool BOM_TABLE_GROUP::HasValueChanged( BOM_COLUMN* aField ) const * * @param aSort - Sort the references */ -wxArrayString BOM_TABLE_GROUP::GetReferences( bool aSort ) const +wxArrayString FIELDS_EDITOR_TABLE_GROUP::GetReferences( bool aSort ) const { wxArrayString refs; @@ -433,7 +433,7 @@ wxArrayString BOM_TABLE_GROUP::GetReferences( bool aSort ) const { if( cmp ) { - refs.Add( cmp->GetFieldValue( BOM_COL_ID_REFERENCE ) ); + refs.Add( cmp->GetFieldValue( FIELDS_EDITOR_COL_ID_REFERENCE ) ); } } @@ -452,7 +452,7 @@ wxArrayString BOM_TABLE_GROUP::GetReferences( bool aSort ) const * e.g. "R100" is lower (alphabetically) than "R19" * BUT should be placed after R19 */ -int BOM_TABLE_GROUP::SortReferences( const wxString& aFirst, const wxString& aSecond ) +int FIELDS_EDITOR_TABLE_GROUP::SortReferences( const wxString& aFirst, const wxString& aSecond ) { // Default sorting int defaultSort = aFirst.Cmp( aSecond ); @@ -512,7 +512,7 @@ int BOM_TABLE_GROUP::SortReferences( const wxString& aFirst, const wxString& aSe * Cases a) to d) should be detected and converted to a common representation * Values that do not match this pattern should revert to standard string comparison */ -int BOM_TABLE_GROUP::SortValues( const wxString& aFirst, const wxString& aSecond ) +int FIELDS_EDITOR_TABLE_GROUP::SortValues( const wxString& aFirst, const wxString& aSecond ) { //TODO - Intelligent comparison of component values // e.g. 4K > 499 @@ -528,9 +528,9 @@ int BOM_TABLE_GROUP::SortValues( const wxString& aFirst, const wxString& aSecond * Create a new COMPONENT row * Each COMPONENT row is associated with a single component item. */ -BOM_TABLE_COMPONENT::BOM_TABLE_COMPONENT( BOM_TABLE_GROUP* aParent, - BOM_COLUMN_LIST* aColumnList, - BOM_FIELD_VALUES* aFieldValues ) +FIELDS_EDITOR_TABLE_COMPONENT::FIELDS_EDITOR_TABLE_COMPONENT( FIELDS_EDITOR_TABLE_GROUP* aParent, + FIELDS_EDITOR_COLUMN_LIST* aColumnList, + FIELDS_EDITOR_FIELD_VALUES* aFieldValues ) { m_parent = aParent; m_columnList = aColumnList; @@ -542,7 +542,7 @@ BOM_TABLE_COMPONENT::BOM_TABLE_COMPONENT( BOM_TABLE_GROUP* aParent, * Try to add a unit to this component * If the references match, it will be added */ -bool BOM_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit ) +bool FIELDS_EDITOR_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit ) { // Addition is successful if the references match or there are currently no units in the group if( Units.size() == 0 || Units[0].GetRef().Cmp( aUnit.GetRef() ) == 0 ) @@ -558,15 +558,15 @@ bool BOM_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit ) switch( column->Id() ) { - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_QUANTITY: value = wxEmptyString; break; - case BOM_COL_ID_DESCRIPTION: + case FIELDS_EDITOR_COL_ID_DESCRIPTION: value = cmp->GetAliasDescription(); break; - case BOM_COL_ID_DATASHEET: + case FIELDS_EDITOR_COL_ID_DATASHEET: value = cmp->GetField( DATASHEET )->GetText(); if( value.IsEmpty() ) { @@ -574,15 +574,15 @@ bool BOM_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit ) } break; - case BOM_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_REFERENCE: value = aUnit.GetRef(); break; - case BOM_COL_ID_VALUE: + case FIELDS_EDITOR_COL_ID_VALUE: value = cmp->GetField( VALUE )->GetText(); break; - case BOM_COL_ID_FOOTPRINT: + case FIELDS_EDITOR_COL_ID_FOOTPRINT: value = cmp->GetField( FOOTPRINT )->GetText(); break; @@ -606,16 +606,16 @@ bool BOM_TABLE_COMPONENT::AddUnit( const SCH_REFERENCE& aUnit ) * Return the value associated with a particular field * If no field is found, return an empty string */ -wxString BOM_TABLE_COMPONENT::GetFieldValue( unsigned int aFieldId ) const +wxString FIELDS_EDITOR_TABLE_COMPONENT::GetFieldValue( unsigned int aFieldId ) const { wxString value; switch ( aFieldId ) { - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_QUANTITY: return wxEmptyString; - case BOM_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_REFERENCE: return GetReference(); default: @@ -642,7 +642,7 @@ wxString BOM_TABLE_COMPONENT::GetFieldValue( unsigned int aFieldId ) const * @param aValue is the new value * @param aOverwrite enforces writing even if a value exists */ -bool BOM_TABLE_COMPONENT::SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite ) +bool FIELDS_EDITOR_TABLE_COMPONENT::SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite ) { if( m_fieldValues ) { @@ -654,7 +654,7 @@ bool BOM_TABLE_COMPONENT::SetFieldValue( unsigned int aFieldId, const wxString a } -wxString BOM_TABLE_COMPONENT::GetPrefix() const +wxString FIELDS_EDITOR_TABLE_COMPONENT::GetPrefix() const { // Return the prefix of a component e.g. "R23" -> "R" if( Units.size() == 0 ) @@ -667,7 +667,7 @@ wxString BOM_TABLE_COMPONENT::GetPrefix() const /** * Return the reference of a component e.g. "R23" */ -wxString BOM_TABLE_COMPONENT::GetReference() const +wxString FIELDS_EDITOR_TABLE_COMPONENT::GetReference() const { if( Units.size() == 0 ) return wxEmptyString; @@ -679,7 +679,7 @@ wxString BOM_TABLE_COMPONENT::GetReference() const /** * Determines if the given field has been changed for this component */ -bool BOM_TABLE_COMPONENT::HasValueChanged( BOM_COLUMN* aField ) const +bool FIELDS_EDITOR_TABLE_COMPONENT::HasValueChanged( FIELDS_EDITOR_COLUMN* aField ) const { if( !aField ) { @@ -694,7 +694,7 @@ bool BOM_TABLE_COMPONENT::HasValueChanged( BOM_COLUMN* aField ) const * If any changes have been made to this component, * they are now applied to the schematic component */ -void BOM_TABLE_COMPONENT::ApplyFieldChanges() +void FIELDS_EDITOR_TABLE_COMPONENT::ApplyFieldChanges() { for( auto& unit : Units ) { @@ -715,19 +715,19 @@ void BOM_TABLE_COMPONENT::ApplyFieldChanges() switch( column->Id() ) { // Ignore read-only fields - case BOM_COL_ID_REFERENCE: - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_QUANTITY: continue; // Special field considerations - case BOM_COL_ID_FOOTPRINT: + case FIELDS_EDITOR_COL_ID_FOOTPRINT: field = cmp->GetField( FOOTPRINT ); break; - case BOM_COL_ID_VALUE: + case FIELDS_EDITOR_COL_ID_VALUE: field = cmp->GetField( VALUE ); break; - case BOM_COL_ID_DATASHEET: + case FIELDS_EDITOR_COL_ID_DATASHEET: field = cmp->GetField( DATASHEET ); break; @@ -758,14 +758,14 @@ void BOM_TABLE_COMPONENT::ApplyFieldChanges() * Revert the displayed fields for this component * to their original values (matching the schematic data) */ -void BOM_TABLE_COMPONENT::RevertFieldChanges() +void FIELDS_EDITOR_TABLE_COMPONENT::RevertFieldChanges() { for( auto& column : m_columnList->Columns ) { switch( column->Id() ) { - case BOM_COL_ID_REFERENCE: - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_REFERENCE: + case FIELDS_EDITOR_COL_ID_QUANTITY: continue; default: break; @@ -776,9 +776,9 @@ void BOM_TABLE_COMPONENT::RevertFieldChanges() } -BOM_TABLE_MODEL::BOM_TABLE_MODEL() : +FIELDS_EDITOR_TABLE_MODEL::FIELDS_EDITOR_TABLE_MODEL() : m_widget( nullptr ), - m_sortingColumn( BOM_COL_ID_REFERENCE ), + m_sortingColumn( FIELDS_EDITOR_COL_ID_REFERENCE ), m_sortingOrder( true ) { //TODO @@ -786,26 +786,26 @@ BOM_TABLE_MODEL::BOM_TABLE_MODEL() : /** - * Create a container for the BOM_TABLE_MODEL + * Create a container for the FIELDS_EDITOR_TABLE_MODEL * This is required for reference counting by wxDataViewCtrl */ -BOM_TABLE_MODEL::MODEL_PTR BOM_TABLE_MODEL::Create() +FIELDS_EDITOR_TABLE_MODEL::MODEL_PTR FIELDS_EDITOR_TABLE_MODEL::Create() { - auto model = new BOM_TABLE_MODEL(); + auto model = new FIELDS_EDITOR_TABLE_MODEL(); - auto container = BOM_TABLE_MODEL::MODEL_PTR( model ); + auto container = FIELDS_EDITOR_TABLE_MODEL::MODEL_PTR( model ); return container; } -BOM_TABLE_MODEL::~BOM_TABLE_MODEL() +FIELDS_EDITOR_TABLE_MODEL::~FIELDS_EDITOR_TABLE_MODEL() { //TODO } -wxDataViewColumn* BOM_TABLE_MODEL::AddColumn( BOM_COLUMN* aColumn, int aPosition ) +wxDataViewColumn* FIELDS_EDITOR_TABLE_MODEL::AddColumn( FIELDS_EDITOR_COLUMN* aColumn, int aPosition ) { static const unsigned int flags = wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_SORTABLE; @@ -875,7 +875,7 @@ wxDataViewColumn* BOM_TABLE_MODEL::AddColumn( BOM_COLUMN* aColumn, int aPosition * Gracefully remove the given column from the wxDataViewCtrl * Removing columns individually prevents bad redraw of entire table */ -bool BOM_TABLE_MODEL::RemoveColumn( BOM_COLUMN* aColumn ) +bool FIELDS_EDITOR_TABLE_MODEL::RemoveColumn( FIELDS_EDITOR_COLUMN* aColumn ) { if( !m_widget || !aColumn ) return false; @@ -899,7 +899,7 @@ bool BOM_TABLE_MODEL::RemoveColumn( BOM_COLUMN* aColumn ) * Attach the MODEL to a particular VIEW * This function causes the view to be updated appropriately */ -void BOM_TABLE_MODEL::AttachTo( wxDataViewCtrl* aView ) +void FIELDS_EDITOR_TABLE_MODEL::AttachTo( wxDataViewCtrl* aView ) { if( !aView ) { @@ -929,7 +929,7 @@ void BOM_TABLE_MODEL::AttachTo( wxDataViewCtrl* aView ) /** * Return the total number of components displayed by the model */ -unsigned int BOM_TABLE_MODEL::ComponentCount() const +unsigned int FIELDS_EDITOR_TABLE_MODEL::ComponentCount() const { unsigned int count = 0; @@ -943,7 +943,7 @@ unsigned int BOM_TABLE_MODEL::ComponentCount() const } -void BOM_TABLE_MODEL::ClearColumns() +void FIELDS_EDITOR_TABLE_MODEL::ClearColumns() { ColumnList.Clear(); } @@ -954,45 +954,45 @@ void BOM_TABLE_MODEL::ClearColumns() * These columns are ALWAYS available in the table * They are immutable - can be hidden by user but not removed */ -void BOM_TABLE_MODEL::AddDefaultColumns() +void FIELDS_EDITOR_TABLE_MODEL::AddDefaultColumns() { // Reference column is read-only - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_REFERENCE, - BOM_COL_TYPE_GENERATED, - BOM_COL_TITLE_REFERENCE, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_REFERENCE, + FIELDS_EDITOR_COL_TYPE_GENERATED, + FIELDS_EDITOR_COL_TITLE_REFERENCE, true, true ) ); - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_VALUE, - BOM_COL_TYPE_KICAD, - BOM_COL_TITLE_VALUE, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_VALUE, + FIELDS_EDITOR_COL_TYPE_KICAD, + FIELDS_EDITOR_COL_TITLE_VALUE, true, false ) ); - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_FOOTPRINT, - BOM_COL_TYPE_KICAD, - BOM_COL_TITLE_FOOTPRINT, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_FOOTPRINT, + FIELDS_EDITOR_COL_TYPE_KICAD, + FIELDS_EDITOR_COL_TITLE_FOOTPRINT, true, false ) ); - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_DATASHEET, - BOM_COL_TYPE_KICAD, - BOM_COL_TITLE_DATASHEET, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_DATASHEET, + FIELDS_EDITOR_COL_TYPE_KICAD, + FIELDS_EDITOR_COL_TITLE_DATASHEET, true, false ) ); // Description comes from .dcm file and is read-only - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_DESCRIPTION, - BOM_COL_TYPE_LIBRARY, - BOM_COL_TITLE_DESCRIPTION, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_DESCRIPTION, + FIELDS_EDITOR_COL_TYPE_LIBRARY, + FIELDS_EDITOR_COL_TITLE_DESCRIPTION, true, true ) ); // Quantity column is read-only - ColumnList.AddColumn( new BOM_COLUMN( - BOM_COL_ID_QUANTITY, - BOM_COL_TYPE_GENERATED, - BOM_COL_TITLE_QUANTITY, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( + FIELDS_EDITOR_COL_ID_QUANTITY, + FIELDS_EDITOR_COL_TYPE_GENERATED, + FIELDS_EDITOR_COL_TITLE_QUANTITY, true, true ) ); } @@ -1001,7 +1001,7 @@ void BOM_TABLE_MODEL::AddDefaultColumns() * Extract field data from all components * Compiles an inclusive list of all field names from all components */ -void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) +void FIELDS_EDITOR_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) { std::vector< SCH_FIELD* > fields; @@ -1036,7 +1036,7 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) if( col->Title().Cmp( fieldName ) == 0 ) { - if( col->Id() >= BOM_COL_ID_USER ) + if( col->Id() >= FIELDS_EDITOR_COL_ID_USER ) { userMatchFound = true; break; @@ -1050,8 +1050,8 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) continue; } - ColumnList.AddColumn( new BOM_COLUMN( ColumnList.NextFieldId(), - BOM_COL_TYPE_USER, + ColumnList.AddColumn( new FIELDS_EDITOR_COLUMN( ColumnList.NextFieldId(), + FIELDS_EDITOR_COL_TYPE_USER, field->GetName(), true, false ) ); } @@ -1062,7 +1062,7 @@ void BOM_TABLE_MODEL::AddComponentFields( SCH_COMPONENT* aCmp ) * Add a list of component items to the BOM manager * Creates consolidated groups of components as required */ -void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields ) +void FIELDS_EDITOR_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields ) { // Add default columns @@ -1083,14 +1083,14 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FI // Add template fields if they are not already added for( auto field : aTemplateFields ) { - BOM_COLUMN* col; + FIELDS_EDITOR_COLUMN* col; col = ColumnList.GetColumnByTitle( field.m_Name ); if( !col ) { - col = new BOM_COLUMN( ColumnList.NextFieldId(), - BOM_COL_TYPE_USER, + col = new FIELDS_EDITOR_COLUMN( ColumnList.NextFieldId(), + FIELDS_EDITOR_COL_TYPE_USER, field.m_Name, true, false ); @@ -1129,7 +1129,7 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FI bool dataFound = false; - BOM_FIELD_VALUES* values; + FIELDS_EDITOR_FIELD_VALUES* values; for( auto& data : m_fieldValues ) { @@ -1143,14 +1143,14 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FI if( !dataFound ) { - values = new BOM_FIELD_VALUES( refDes, &m_fieldTemplates ); - m_fieldValues.push_back( std::unique_ptr( values ) ); + values = new FIELDS_EDITOR_FIELD_VALUES( refDes, &m_fieldTemplates ); + m_fieldValues.push_back( std::unique_ptr( values ) ); } - auto* newComponent = new BOM_TABLE_COMPONENT( nullptr, &ColumnList, values ); + auto* newComponent = new FIELDS_EDITOR_TABLE_COMPONENT( nullptr, &ColumnList, values ); newComponent->AddUnit( ref ); - m_components.push_back( std::unique_ptr( newComponent ) ); + m_components.push_back( std::unique_ptr( newComponent ) ); } } @@ -1158,7 +1158,7 @@ void BOM_TABLE_MODEL::SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FI } -void BOM_TABLE_MODEL::SetBackupPoint() +void FIELDS_EDITOR_TABLE_MODEL::SetBackupPoint() { // Mark backup locations for all values for( auto& vals : m_fieldValues ) @@ -1171,7 +1171,7 @@ void BOM_TABLE_MODEL::SetBackupPoint() /** * Recalculate grouping of components and reload table **/ -void BOM_TABLE_MODEL::ReloadTable() +void FIELDS_EDITOR_TABLE_MODEL::ReloadTable() { if( m_widget ) { @@ -1202,11 +1202,11 @@ void BOM_TABLE_MODEL::ReloadTable() // No suitable group was found for this component if( !grouped ) { - auto* newGroup = new BOM_TABLE_GROUP( &ColumnList ); + auto* newGroup = new FIELDS_EDITOR_TABLE_GROUP( &ColumnList ); newGroup->AddComponent( &*cmp ); - Groups.push_back( std::unique_ptr( newGroup ) ); + Groups.push_back( std::unique_ptr( newGroup ) ); } } @@ -1223,7 +1223,7 @@ void BOM_TABLE_MODEL::ReloadTable() /** * Return a string array of data from a given row */ -wxArrayString BOM_TABLE_MODEL::GetRowData( unsigned int aRow, std::vector aColumns ) const +wxArrayString FIELDS_EDITOR_TABLE_MODEL::GetRowData( unsigned int aRow, std::vector aColumns ) const { wxArrayString row; @@ -1255,7 +1255,7 @@ wxArrayString BOM_TABLE_MODEL::GetRowData( unsigned int aRow, std::vector( item.GetID() ); + auto selectedRow = static_cast( item.GetID() ); if( selectedRow ) { @@ -1317,7 +1317,7 @@ bool BOM_TABLE_MODEL::SetValue( const wxVariant& aVariant, const wxDataViewItem& * Return the parent item for a given item in the model. * If no parent is found (or the item is invalid) return an invalid item. */ -wxDataViewItem BOM_TABLE_MODEL::GetParent( const wxDataViewItem& aItem ) const +wxDataViewItem FIELDS_EDITOR_TABLE_MODEL::GetParent( const wxDataViewItem& aItem ) const { auto row = ItemToRow( aItem ); auto parent = row ? row->GetParent() : nullptr; @@ -1335,7 +1335,7 @@ wxDataViewItem BOM_TABLE_MODEL::GetParent( const wxDataViewItem& aItem ) const /** * Returns true if the supplied item has children */ -bool BOM_TABLE_MODEL::IsContainer( const wxDataViewItem& aItem ) const +bool FIELDS_EDITOR_TABLE_MODEL::IsContainer( const wxDataViewItem& aItem ) const { auto row = ItemToRow( aItem ); @@ -1352,7 +1352,7 @@ bool BOM_TABLE_MODEL::IsContainer( const wxDataViewItem& aItem ) const * Push all children of the supplied item into the list * If the supplied item is invalid, push all the top-level items */ -unsigned int BOM_TABLE_MODEL::GetChildren( const wxDataViewItem& aItem, +unsigned int FIELDS_EDITOR_TABLE_MODEL::GetChildren( const wxDataViewItem& aItem, wxDataViewItemArray& aChildren ) const { auto row = aItem.IsOk() ? ItemToRow( aItem ) : nullptr; @@ -1374,7 +1374,7 @@ unsigned int BOM_TABLE_MODEL::GetChildren( const wxDataViewItem& aItem, } -bool BOM_TABLE_MODEL::GetAttr( const wxDataViewItem& aItem, +bool FIELDS_EDITOR_TABLE_MODEL::GetAttr( const wxDataViewItem& aItem, unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const { @@ -1394,7 +1394,7 @@ bool BOM_TABLE_MODEL::GetAttr( const wxDataViewItem& aItem, * Alphanumeric sorting is not sufficient for correct ordering of some fields * Some columns are sorted numerically, others with more complex rules. */ -int BOM_TABLE_MODEL::Compare( const wxDataViewItem& aItem1, +int FIELDS_EDITOR_TABLE_MODEL::Compare( const wxDataViewItem& aItem1, const wxDataViewItem& aItem2, unsigned int aColumnId, bool aAscending ) const @@ -1422,16 +1422,16 @@ int BOM_TABLE_MODEL::Compare( const wxDataViewItem& aItem1, switch( aColumnId ) { // Reference column sorted by reference val - case BOM_COL_ID_REFERENCE: - result = BOM_TABLE_GROUP::SortReferences( strVal1, strVal2 ); + case FIELDS_EDITOR_COL_ID_REFERENCE: + result = FIELDS_EDITOR_TABLE_GROUP::SortReferences( strVal1, strVal2 ); break; - case BOM_COL_ID_VALUE: - result = BOM_TABLE_GROUP::SortValues( strVal1, strVal2 ); + case FIELDS_EDITOR_COL_ID_VALUE: + result = FIELDS_EDITOR_TABLE_GROUP::SortValues( strVal1, strVal2 ); break; // These columns are sorted numerically - case BOM_COL_ID_QUANTITY: + case FIELDS_EDITOR_COL_ID_QUANTITY: if( strVal1.ToLong( &numVal1 ) && strVal2.ToLong( &numVal2 ) ) { result = numVal1 - numVal2; @@ -1449,19 +1449,19 @@ int BOM_TABLE_MODEL::Compare( const wxDataViewItem& aItem1, } // If initial sorting failed, sort secondly by reference - if( result == 0 && aColumnId != BOM_COL_ID_REFERENCE ) + if( result == 0 && aColumnId != FIELDS_EDITOR_COL_ID_REFERENCE ) { - result = BOM_TABLE_GROUP::SortReferences( - row1->GetFieldValue( BOM_COL_ID_REFERENCE ), - row2->GetFieldValue( BOM_COL_ID_REFERENCE ) ); + result = FIELDS_EDITOR_TABLE_GROUP::SortReferences( + row1->GetFieldValue( FIELDS_EDITOR_COL_ID_REFERENCE ), + row2->GetFieldValue( FIELDS_EDITOR_COL_ID_REFERENCE ) ); } // If sorting still failed, sort thirdly by value - if( result == 0 && aColumnId != BOM_COL_ID_VALUE ) + if( result == 0 && aColumnId != FIELDS_EDITOR_COL_ID_VALUE ) { - result = BOM_TABLE_GROUP::SortValues( - row1->GetFieldValue( BOM_COL_ID_VALUE ), - row2->GetFieldValue( BOM_COL_ID_VALUE ) ); + result = FIELDS_EDITOR_TABLE_GROUP::SortValues( + row1->GetFieldValue( FIELDS_EDITOR_COL_ID_VALUE ), + row2->GetFieldValue( FIELDS_EDITOR_COL_ID_VALUE ) ); } if( !aAscending ) @@ -1477,7 +1477,7 @@ int BOM_TABLE_MODEL::Compare( const wxDataViewItem& aItem1, * Revert all component data back to the original values. * The table view is updated accordingly */ -void BOM_TABLE_MODEL::RevertFieldChanges() +void FIELDS_EDITOR_TABLE_MODEL::RevertFieldChanges() { for( auto& group : Groups ) { @@ -1512,7 +1512,7 @@ void BOM_TABLE_MODEL::RevertFieldChanges() * Apply all outstanding field changes. * This is performed only when the window is closed */ -void BOM_TABLE_MODEL::ApplyFieldChanges() +void FIELDS_EDITOR_TABLE_MODEL::ApplyFieldChanges() { for( auto& group : Groups ) { @@ -1536,7 +1536,7 @@ void BOM_TABLE_MODEL::ApplyFieldChanges() /** * Tests if any component values in the table have been altered */ -bool BOM_TABLE_MODEL::HaveFieldsChanged() const +bool FIELDS_EDITOR_TABLE_MODEL::HaveFieldsChanged() const { for( auto const& group : Groups ) { @@ -1562,7 +1562,7 @@ bool BOM_TABLE_MODEL::HaveFieldsChanged() const /** * Returns a list of only those components that have been changed */ -std::vector BOM_TABLE_MODEL::GetChangedComponents() +std::vector FIELDS_EDITOR_TABLE_MODEL::GetChangedComponents() { std::vector components; @@ -1593,7 +1593,7 @@ std::vector BOM_TABLE_MODEL::GetChangedComponents() /** * Returns a count of the components that have been changed */ -unsigned int BOM_TABLE_MODEL::CountChangedComponents() +unsigned int FIELDS_EDITOR_TABLE_MODEL::CountChangedComponents() { unsigned int count = 0; diff --git a/eeschema/fields_editor_table_model.h b/eeschema/fields_editor_table_model.h index 53058e527c..b5aeb98f49 100644 --- a/eeschema/fields_editor_table_model.h +++ b/eeschema/fields_editor_table_model.h @@ -22,8 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef _EESCHEMA_BOM_TABLE_MODEL_H_ -#define _EESCHEMA_BOM_TABLE_MODEL_H_ +#ifndef FIELDS_EDITOR_TABLE_MODEL_H +#define FIELDS_EDITOR_TABLE_MODEL_H #include #include @@ -36,29 +36,29 @@ #include #include -#include "bom_table_column.h" +#include "fields_editor_table_column.h" // Forward-declare classes -class BOM_TABLE_ROW; // Base-class for table row data model -class BOM_TABLE_GROUP; // Class for displaying a group of components -class BOM_TABLE_COMPONENT; // Class for displaying a single component +class FIELDS_EDITOR_TABLE_ROW; // Base-class for table row data model +class FIELDS_EDITOR_TABLE_GROUP; // Class for displaying a group of components +class FIELDS_EDITOR_TABLE_COMPONENT; // Class for displaying a single component // Map column IDs to field values (for quick lookup) typedef std::map FIELD_VALUE_MAP; /** - * The BOM_FIELD_VALUES class provides quick lookup of component values + * The FIELDS_EDITOR_FIELD_VALUES class provides quick lookup of component values * (based on Field ID) * This is done for the following reasons: * - Increase lookup speed for table values * - Allow field values to be reverted to original values * - Allow duplicate components to reference the same data */ -class BOM_FIELD_VALUES +class FIELDS_EDITOR_FIELD_VALUES { public: - BOM_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate ); + FIELDS_EDITOR_FIELD_VALUES( const wxString& aRefDes, FIELD_VALUE_MAP* aTemplate ); /** * Return the current value for the provided field ID @@ -122,11 +122,11 @@ protected: * COMPONENT - Displays a single component * UNIT - Child of COMPONENT for multi-unit components */ -class BOM_TABLE_ROW +class FIELDS_EDITOR_TABLE_ROW { public: - BOM_TABLE_ROW(); - virtual ~BOM_TABLE_ROW() {} + FIELDS_EDITOR_TABLE_ROW(); + virtual ~FIELDS_EDITOR_TABLE_ROW() {} /// Set display properties for a cell virtual bool GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const; @@ -138,7 +138,7 @@ public: virtual bool SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite = false ) = 0; /// Return parent item - virtual BOM_TABLE_ROW* GetParent() const { return nullptr; } + virtual FIELDS_EDITOR_TABLE_ROW* GetParent() const { return nullptr; } /// Test if row has any child rows virtual bool HasChildren() const { return false; } @@ -147,7 +147,7 @@ public: virtual unsigned int GetChildren( wxDataViewItemArray& aChildren ) const { return 0; } /// Determine if a value has changed - virtual bool HasValueChanged( BOM_COLUMN* aField ) const { return false; } + virtual bool HasValueChanged( FIELDS_EDITOR_COLUMN* aField ) const { return false; } /// Determine if any values have changed bool HasChanged() const; @@ -155,22 +155,22 @@ public: protected: /// Pointer to list of columns - BOM_COLUMN_LIST* m_columnList; + FIELDS_EDITOR_COLUMN_LIST* m_columnList; }; /** - * BOM_TABLE_GROUP class displays a group of similar components + * FIELDS_EDITOR_TABLE_GROUP class displays a group of similar components * If the group contains more than one component, * they are each displayed as child items of the group */ -class BOM_TABLE_GROUP : public BOM_TABLE_ROW +class FIELDS_EDITOR_TABLE_GROUP : public FIELDS_EDITOR_TABLE_ROW { public: /// List of components stored in this group - std::vector Components; + std::vector Components; - BOM_TABLE_GROUP( BOM_COLUMN_LIST* aColumnList ); - virtual ~BOM_TABLE_GROUP() {} + FIELDS_EDITOR_TABLE_GROUP( FIELDS_EDITOR_COLUMN_LIST* aColumnList ); + virtual ~FIELDS_EDITOR_TABLE_GROUP() {} /// Set display properties for a group row virtual bool GetAttr( unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const override; @@ -182,7 +182,7 @@ public: virtual bool SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite = false ) override; /// Attempt to add a new component to the group - bool AddComponent( BOM_TABLE_COMPONENT* aComponent ); + bool AddComponent( FIELDS_EDITOR_TABLE_COMPONENT* aComponent ); /// Test if this group should display children virtual bool HasChildren() const override { return Components.size() > 1; } @@ -191,7 +191,7 @@ public: virtual unsigned int GetChildren( wxDataViewItemArray& aChildren ) const override; /// Test if any children have changed - virtual bool HasValueChanged( BOM_COLUMN* aField ) const override; + virtual bool HasValueChanged( FIELDS_EDITOR_COLUMN* aField ) const override; /// Return the number of child items in this group unsigned int GroupSize( void ) const { return Components.size(); } @@ -207,16 +207,16 @@ public: protected: /// Test if a particular field matches against another component - bool TestField( BOM_COLUMN* aField, BOM_TABLE_COMPONENT* aComponent ) const; + bool TestField( FIELDS_EDITOR_COLUMN* aField, FIELDS_EDITOR_TABLE_COMPONENT* aComponent ) const; }; -class BOM_TABLE_COMPONENT : public BOM_TABLE_ROW +class FIELDS_EDITOR_TABLE_COMPONENT : public FIELDS_EDITOR_TABLE_ROW { public: // List of units associated with this component std::vector Units; - BOM_TABLE_COMPONENT( BOM_TABLE_GROUP* aParent, BOM_COLUMN_LIST* aColumnList, BOM_FIELD_VALUES* aValues ); + FIELDS_EDITOR_TABLE_COMPONENT( FIELDS_EDITOR_TABLE_GROUP* aParent, FIELDS_EDITOR_COLUMN_LIST* aColumnList, FIELDS_EDITOR_FIELD_VALUES* aValues ); bool AddUnit( const SCH_REFERENCE& aUnit ); @@ -224,7 +224,7 @@ public: virtual bool SetFieldValue( unsigned int aFieldId, const wxString aValue, bool aOverwrite = false ) override; - virtual bool HasValueChanged( BOM_COLUMN* aField ) const override; + virtual bool HasValueChanged( FIELDS_EDITOR_COLUMN* aField ) const override; /// Return the reference of the first unit (all units must be the same wxString GetReference() const; @@ -238,33 +238,33 @@ public: void RevertFieldChanges(); - void SetParent( BOM_TABLE_GROUP* aParent ) { m_parent = aParent; } + void SetParent( FIELDS_EDITOR_TABLE_GROUP* aParent ) { m_parent = aParent; } - virtual BOM_TABLE_ROW* GetParent() const override { return m_parent; } + virtual FIELDS_EDITOR_TABLE_ROW* GetParent() const override { return m_parent; } protected: - BOM_TABLE_GROUP* m_parent; + FIELDS_EDITOR_TABLE_GROUP* m_parent; - BOM_FIELD_VALUES* m_fieldValues; + FIELDS_EDITOR_FIELD_VALUES* m_fieldValues; }; /** - * BOM_TABLE_MODEL class + * FIELDS_EDITOR_TABLE_MODEL class * * Contains complete BOM information: * a) List of columns (fields) to display * b) List of groups of consolidated components */ -class BOM_TABLE_MODEL : public wxDataViewModel +class FIELDS_EDITOR_TABLE_MODEL : public wxDataViewModel { protected: - BOM_TABLE_MODEL(); + FIELDS_EDITOR_TABLE_MODEL(); // Vector of unique component rows - std::vector> m_components; + std::vector> m_components; // Vector of field values mapped to field IDs - std::vector> m_fieldValues; + std::vector> m_fieldValues; // Template field values FIELD_VALUE_MAP m_fieldTemplates; @@ -304,21 +304,21 @@ protected: public: - virtual ~BOM_TABLE_MODEL(); + virtual ~FIELDS_EDITOR_TABLE_MODEL(); - BOM_COLUMN_LIST ColumnList; + FIELDS_EDITOR_COLUMN_LIST ColumnList; /// List of component groups - std::vector> Groups; + std::vector> Groups; - typedef wxObjectDataPtr MODEL_PTR; + typedef wxObjectDataPtr MODEL_PTR; static MODEL_PTR Create(); void AttachTo( wxDataViewCtrl* aView ); - wxDataViewColumn* AddColumn( BOM_COLUMN* aColumn, int aPosition = -1 ); - bool RemoveColumn( BOM_COLUMN* aColumn ); + wxDataViewColumn* AddColumn( FIELDS_EDITOR_COLUMN* aColumn, int aPosition = -1 ); + bool RemoveColumn( FIELDS_EDITOR_COLUMN* aColumn ); // wxDataViewModel functions virtual bool GetAttr( const wxDataViewItem& aItem, unsigned int aFieldId, wxDataViewItemAttr& aAttr ) const override; @@ -343,7 +343,7 @@ public: void SetBlankMerging( const bool aMerge = true ) { m_mergeBlankFields = aMerge; } bool GetBlankMerging() const { return m_mergeBlankFields; } - wxArrayString GetRowData( unsigned int aRow, std::vector aColumns ) const; + wxArrayString GetRowData( unsigned int aRow, std::vector aColumns ) const; void SetComponents( SCH_REFERENCE_LIST aRefs, const TEMPLATE_FIELDNAMES& aTemplateFields ); void AddComponentFields( SCH_COMPONENT* aCmp ); @@ -359,4 +359,4 @@ public: unsigned int CountChangedComponents(); }; -#endif // _EESCHEMA_BOM_TABLE_MODEL_H_ +#endif // FIELDS_EDITOR_TABLE_MODEL_H