Add options editor to symbol library table + cleanup unused options

This commit is contained in:
Roberto Fernandez Bautista 2023-05-28 22:09:20 +02:00
parent a119bd604d
commit 688a61df63
3 changed files with 36 additions and 39 deletions

View File

@ -28,13 +28,11 @@ LIB_TABLE_GRID_TRICKS::LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid ) : GRID_TRICKS( aG
void LIB_TABLE_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
{
if( m_grid->GetGridCursorCol() == COL_OPTIONS )
{
menu.Append( LIB_TABLE_GRID_TRICKS_OPTIONS_EDITOR,
_( "Options Editor..." ),
_( "Edit options" ) );
menu.AppendSeparator();
}
menu.Append( LIB_TABLE_GRID_TRICKS_OPTIONS_EDITOR,
_( "Edit options..." ),
_( "Edit options for this library entry" ) );
menu.AppendSeparator();
bool showActivate = false;
bool showDeactivate = false;

View File

@ -23,6 +23,7 @@
#include <wx/regex.h>
#include <common.h> // For ExpandEnvVarSubstitutions
#include <dialogs/dialog_plugin_options.h>
#include <project.h>
#include <panel_sym_lib_table.h>
#include <lib_id.h>
@ -140,7 +141,29 @@ protected:
virtual void optionsEditor( int aRow )
{
DisplayError( m_dialog, _( "optionsEditor not implemented in SYMBOL_GRID_TRICKS" ) );
SYMBOL_LIB_TABLE_GRID* tbl = (SYMBOL_LIB_TABLE_GRID*) m_grid->GetTable();
if( tbl->GetNumberRows() > aRow )
{
LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
const wxString& options = row->GetOptions();
wxString result = options;
STRING_UTF8_MAP choices;
SCH_IO_MGR::SCH_FILE_T pi_type = SCH_IO_MGR::EnumFromStr( row->GetType() );
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( pi_type ) );
pi->SymbolLibOptions( &choices );
DIALOG_PLUGIN_OPTIONS dlg( m_dialog, row->GetNickName(), choices, options, &result );
dlg.ShowModal();
if( options != result )
{
row->SetOptions( result );
m_grid->Refresh();
}
}
}
/// handle specialized clipboard text, with leading "(sym_lib_table" or

View File

@ -118,37 +118,13 @@ bool SCH_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
void SCH_PLUGIN::SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
{
// disable all these in another couple of months, after everyone has seen them:
#if 1
(*aListToAppendTo)["debug_level"] = UTF8( _(
"Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
) );
(*aListToAppendTo)["read_filter_regex"] = UTF8( _(
"Regular expression <b>symbol name</b> filter."
) );
(*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
"Enable transaction logging. The mere presence of this option turns on the "
"logging, no need to set a Value."
) );
(*aListToAppendTo)["username"] = UTF8( _(
"User name for <b>login</b> to some special library server."
) );
(*aListToAppendTo)["password"] = UTF8( _(
"Password for <b>login</b> to some special library server."
) );
#endif
#if 1
// Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
// if and when implemented.
(*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
"Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
) );
#endif
// Empty for most plugins
//
// To add a new option override and use example code below:
//
//(*aListToAppendTo)["new_option_name"] = UTF8( _(
// "A nice descrtiption with possibility for <b>bold</b> and other formatting."
// ) );
}