diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 411a20f395..d7536f8d5d 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -106,6 +106,26 @@ protected: } public: + void SetValue( int aRow, int aCol, const wxString &aValue ) override + { + LIB_TABLE_GRID::SetValue( aRow, aCol, aValue ); + + // If setting a filepath, attempt to auto-detect the format + if( aCol == COL_URI ) + { + wxFileName fn( aValue ); + + for( SCH_IO_MGR::SCH_FILE_T piType : SCH_IO_MGR::SCH_FILE_T_vector ) + { + if( SCH_IO_MGR::GetLibraryFileExtension( piType ).Lower() == fn.GetExt().Lower() ) + { + SetValue( aRow, COL_TYPE, SCH_IO_MGR::ShowType( piType ) ); + break; + } + } + } + } + SYMBOL_LIB_TABLE_GRID( const SYMBOL_LIB_TABLE& aTableToEdit ) { @@ -176,7 +196,7 @@ protected: }; -PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PROJECT* aProject , +PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent, PROJECT* aProject, SYMBOL_LIB_TABLE* aGlobalTable, const wxString& aGlobalTablePath, SYMBOL_LIB_TABLE* aProjectTable, @@ -467,26 +487,20 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); wxString openDir = cfg->m_lastSymbolLibDir; - if( m_cur_grid == m_project_grid ) - { - openDir = m_lastProjectLibDir; - } - wxFileDialog dlg( this, _( "Select Library" ), - openDir, wxEmptyString, wildcards, + if( m_cur_grid == m_project_grid ) + openDir = m_lastProjectLibDir; + + wxFileDialog dlg( this, _( "Select Library" ), openDir, wxEmptyString, wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( m_cur_grid == m_global_grid ) - { cfg->m_lastSymbolLibDir = dlg.GetPath(); - } else - { m_lastProjectLibDir = dlg.GetPath(); - } const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables(); bool addDuplicates = false; @@ -525,10 +539,7 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname ); - // TODO the following code can detect only schematic types, not libs - // SCH_IO_MGR needs to provide file extension information for libraries too - - // auto detect the plugin type + // attempt to auto-detect the plugin type for( SCH_IO_MGR::SCH_FILE_T piType : SCH_IO_MGR::SCH_FILE_T_vector ) { if( SCH_IO_MGR::GetLibraryFileExtension( piType ).Lower() == fn.GetExt().Lower() )