Browse Source

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)

(cherry picked from commit 9b14434fc3)
9.0
John Beard 1 month ago
committed by Seth Hillbrand
parent
commit
6fcfcd28ca
  1. 15
      eeschema/dialogs/dialog_lib_fields.cpp
  2. 4
      eeschema/dialogs/dialog_lib_fields.h
  3. 6
      eeschema/tools/symbol_editor_control.cpp

15
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 );
}

4
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;

6
eeschema/tools/symbol_editor_control.cpp

@ -944,7 +944,11 @@ int SYMBOL_EDITOR_CONTROL::ShowLibraryTable( const TOOL_EVENT& aEvent )
SYMBOL_EDIT_FRAME* editFrame = getEditFrame<SYMBOL_EDIT_FRAME>();
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;

Loading…
Cancel
Save