From 9b14434fc3490474d33f9096e5d353471e76f0df Mon Sep 17 00:00:00 2001 From: John Beard Date: Tue, 2 Sep 2025 18:28:23 +0800 Subject: [PATCH] Symbol editor: allow to inject the symbol list into DIALOG_LIB_FIELDS This will permit editing fields for subsets (e.g. only symbols in a certain inheritance hierarchy) --- eeschema/dialogs/dialog_lib_fields.cpp | 15 +++++---------- eeschema/dialogs/dialog_lib_fields.h | 4 ++-- eeschema/tools/symbol_editor_control.cpp | 6 +++++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_fields.cpp b/eeschema/dialogs/dialog_lib_fields.cpp index 54e6eeb679..e9507aabdb 100644 --- a/eeschema/dialogs/dialog_lib_fields.cpp +++ b/eeschema/dialogs/dialog_lib_fields.cpp @@ -235,13 +235,13 @@ protected: }; -DIALOG_LIB_FIELDS::DIALOG_LIB_FIELDS( SYMBOL_EDIT_FRAME* parent, wxString libId ) : +DIALOG_LIB_FIELDS::DIALOG_LIB_FIELDS( SYMBOL_EDIT_FRAME* parent, wxString libId, const wxArrayString& aSymbolNames ) : DIALOG_LIB_FIELDS_BASE( parent, wxID_ANY, wxString::Format( _( "Symbol Library Fields: %s" ), libId ) ), m_libId( libId ), m_parent( parent ) { // Get all symbols from the library - loadSymbols(); + loadSymbols( aSymbolNames ); m_bRefresh->SetBitmap( KiBitmapBundle( BITMAPS::small_refresh ) ); @@ -392,25 +392,21 @@ void DIALOG_LIB_FIELDS::OnInit() } -void DIALOG_LIB_FIELDS::loadSymbols() +void DIALOG_LIB_FIELDS::loadSymbols( const wxArrayString& aSymbolNames ) { // Clear any existing data m_symbolsList.clear(); try { - // Get all symbol names from the library manager - wxArrayString symbolNames; - m_parent->GetLibManager().GetSymbolNames( m_libId, symbolNames ); - - if( symbolNames.IsEmpty() ) + if( aSymbolNames.IsEmpty() ) { wxMessageBox( wxString::Format( _( "No symbols found in library %s." ), m_libId ) ); return; } // Load each symbol from the library manager and add it to our list - for( const wxString& symbolName : symbolNames ) + for( const wxString& symbolName : aSymbolNames ) { LIB_SYMBOL* symbol = nullptr; @@ -1154,4 +1150,3 @@ void DIALOG_LIB_FIELDS::SetupAllColumnProperties() m_dataModel->SetSorting( sortCol, sortAscending ); m_grid->SetSortingColumn( sortCol, sortAscending ); } - diff --git a/eeschema/dialogs/dialog_lib_fields.h b/eeschema/dialogs/dialog_lib_fields.h index 4856223d86..52159f0ba6 100644 --- a/eeschema/dialogs/dialog_lib_fields.h +++ b/eeschema/dialogs/dialog_lib_fields.h @@ -30,7 +30,7 @@ class LIB_SYMBOL; class DIALOG_LIB_FIELDS : public DIALOG_LIB_FIELDS_BASE { public: - DIALOG_LIB_FIELDS( SYMBOL_EDIT_FRAME* parent, wxString libId ); + DIALOG_LIB_FIELDS( SYMBOL_EDIT_FRAME* parent, wxString libId, const wxArrayString& aSymbolNames ); ~DIALOG_LIB_FIELDS() override; void OnInit(); @@ -68,7 +68,7 @@ private: void SetupColumnProperties( int aCol ); void SetupAllColumnProperties(); - void loadSymbols(); + void loadSymbols( const wxArrayString& aSymbolNames ); wxString m_libId; SYMBOL_EDIT_FRAME* m_parent; diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index c75f0c8215..8be18cc9aa 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -921,7 +921,11 @@ int SYMBOL_EDITOR_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent ) SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); wxString libName = editFrame->GetTreeLIBID().GetLibNickname(); - DIALOG_LIB_FIELDS dlg( editFrame, libName ); + // Get all symbol names from the library manager + wxArrayString symbolNames; + editFrame->GetLibManager().GetSymbolNames( libName, symbolNames ); + + DIALOG_LIB_FIELDS dlg( editFrame, libName, symbolNames ); dlg.SetTitle( _( "Library Fields" ) ); dlg.ShowModal(); return 0;