Allow keywords to be selected as a chooser column.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/22644
This commit is contained in:
@@ -1193,16 +1193,14 @@ void FIELDS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
|
||||
&& m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
&& !m_grid->IsReadOnly( getFieldRow( FIELD_T::FOOTPRINT ), FDC_VALUE ) )
|
||||
{
|
||||
menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ),
|
||||
_( "Browse for footprint" ) );
|
||||
menu.Append( MYID_SELECT_FOOTPRINT, _( "Select Footprint..." ), _( "Browse for footprint" ) );
|
||||
menu.AppendSeparator();
|
||||
}
|
||||
else if( m_grid->GetGridCursorRow() == getFieldRow( FIELD_T::DATASHEET )
|
||||
&& m_grid->GetGridCursorCol() == FDC_VALUE
|
||||
&& !m_grid->IsReadOnly( getFieldRow( FIELD_T::DATASHEET ), FDC_VALUE ) )
|
||||
{
|
||||
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ),
|
||||
_( "Show datasheet in browser" ) );
|
||||
menu.Append( MYID_SHOW_DATASHEET, _( "Show Datasheet" ), _( "Show datasheet in browser" ) );
|
||||
menu.AppendSeparator();
|
||||
}
|
||||
|
||||
|
||||
@@ -162,6 +162,11 @@ void LIB_SYMBOL::GetChooserFields( std::map<wxString, wxString>& aColumnMap )
|
||||
if( field->ShowInChooser() )
|
||||
aColumnMap[field->GetName()] = field->EDA_TEXT::GetShownText( false );
|
||||
}
|
||||
|
||||
// If the user has a field named "Keywords", then prefer that. Otherwise add the KiCad
|
||||
// keywords.
|
||||
if( !aColumnMap.contains( _( "Keywords" ) ) )
|
||||
aColumnMap[_( "Keywords" )] = GetShownKeyWords();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -154,17 +154,15 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
|
||||
footprint = candidate;
|
||||
|
||||
// Datasheet
|
||||
candidate = m_resolveTextVars
|
||||
? symbol2->GetField( FIELD_T::DATASHEET )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DATASHEET )->GetText();
|
||||
candidate = m_resolveTextVars ? symbol2->GetField( FIELD_T::DATASHEET )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DATASHEET )->GetText();
|
||||
|
||||
if( !candidate.IsEmpty() && ( unit < minUnit || datasheet.IsEmpty() ) )
|
||||
datasheet = candidate;
|
||||
|
||||
// Description
|
||||
candidate = m_resolveTextVars
|
||||
? symbol2->GetField( FIELD_T::DESCRIPTION )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DESCRIPTION )->GetText();
|
||||
candidate = m_resolveTextVars ? symbol2->GetField( FIELD_T::DESCRIPTION )->GetShownText( &sheet, false )
|
||||
: symbol2->GetField( FIELD_T::DESCRIPTION )->GetText();
|
||||
|
||||
if( !candidate.IsEmpty() && ( unit < minUnit || description.IsEmpty() ) )
|
||||
description = candidate;
|
||||
|
||||
@@ -1769,16 +1769,20 @@ bool SCH_IO_KICAD_SEXPR::DeleteLibrary( const wxString& aLibraryPath,
|
||||
if( !fn.IsDir() )
|
||||
{
|
||||
if( wxRemove( aLibraryPath ) )
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "Symbol library file '%s' cannot be deleted." ),
|
||||
aLibraryPath.GetData() ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This may be overly agressive. Perhaps in the future we should remove all of the *.kicad_sym
|
||||
// files and only delete the folder if it's empty.
|
||||
if( !fn.Rmdir( wxPATH_RMDIR_RECURSIVE ) )
|
||||
{
|
||||
THROW_IO_ERROR( wxString::Format( _( "Symbol library folder '%s' cannot be deleted." ),
|
||||
fn.GetPath() ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( m_cache && m_cache->IsFile( aLibraryPath ) )
|
||||
@@ -1791,8 +1795,7 @@ bool SCH_IO_KICAD_SEXPR::DeleteLibrary( const wxString& aLibraryPath,
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath,
|
||||
const std::map<std::string, UTF8>* aProperties )
|
||||
void SCH_IO_KICAD_SEXPR::SaveLibrary( const wxString& aLibraryPath, const std::map<std::string, UTF8>* aProperties )
|
||||
{
|
||||
if( !m_cache )
|
||||
m_cache = new SCH_IO_KICAD_SEXPR_LIB_CACHE( aLibraryPath );
|
||||
@@ -1843,18 +1846,11 @@ void SCH_IO_KICAD_SEXPR::GetAvailableSymbolFields( std::vector<wxString>& aNames
|
||||
|
||||
for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it )
|
||||
{
|
||||
std::vector<SCH_FIELD*> fields;
|
||||
it->second->GetFields( fields );
|
||||
std::map<wxString, wxString> chooserFields;
|
||||
it->second->GetChooserFields( chooserFields );
|
||||
|
||||
for( SCH_FIELD* field : fields )
|
||||
{
|
||||
if( field->IsMandatory() )
|
||||
continue;
|
||||
|
||||
// TODO(JE): enable configurability of this outside database libraries?
|
||||
// if( field->ShowInChooser() )
|
||||
fieldNames.insert( field->GetName() );
|
||||
}
|
||||
for( const auto& [name, value] : chooserFields )
|
||||
fieldNames.insert( name );
|
||||
}
|
||||
|
||||
std::copy( fieldNames.begin(), fieldNames.end(), std::back_inserter( aNames ) );
|
||||
@@ -1867,8 +1863,7 @@ void SCH_IO_KICAD_SEXPR::GetDefaultSymbolFields( std::vector<wxString>& aNames )
|
||||
}
|
||||
|
||||
|
||||
std::vector<LIB_SYMBOL*> SCH_IO_KICAD_SEXPR::ParseLibSymbols( std::string& aSymbolText,
|
||||
std::string aSource,
|
||||
std::vector<LIB_SYMBOL*> SCH_IO_KICAD_SEXPR::ParseLibSymbols( std::string& aSymbolText, std::string aSource,
|
||||
int aFileVersion )
|
||||
{
|
||||
LIB_SYMBOL* newSymbol = nullptr;
|
||||
|
||||
@@ -54,12 +54,9 @@ SYMBOL_TREE_MODEL_ADAPTER::SYMBOL_TREE_MODEL_ADAPTER( SCH_BASE_FRAME* aParent, S
|
||||
{
|
||||
m_colWidths[ GetDefaultFieldName( FIELD_T::VALUE, false ) ] = 300;
|
||||
m_colWidths[ GetDefaultFieldName( FIELD_T::FOOTPRINT, false ) ] = 600;
|
||||
m_colWidths[ GetDefaultFieldName( FIELD_T::DATASHEET, false ) ] = 600;
|
||||
|
||||
m_availableColumns.emplace_back( GetDefaultFieldName( FIELD_T::VALUE, false ) );
|
||||
m_availableColumns.emplace_back( GetDefaultFieldName( FIELD_T::FOOTPRINT, false ) );
|
||||
// Datasheet probably isn't useful, but better to leave that decision to the user:
|
||||
m_availableColumns.emplace_back( GetDefaultFieldName( FIELD_T::DATASHEET, false ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user