Only load all the libraries for a keyword or wildcard search.

This commit is contained in:
Jeff Young 2018-02-22 01:21:46 +00:00 committed by Maciej Suminski
parent 60a9befe7c
commit cb77babe52
1 changed files with 31 additions and 29 deletions

View File

@ -199,40 +199,42 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
return NULL; return NULL;
} }
// While some of the search methods can load a libraray at a time (and stop when if( dlg.IsKeyword() || moduleName.Contains( wxT( "?" ) ) || moduleName.Contains( wxT( "*" ) ) )
// a match is found), the async loader gives much better feedback and loads the
// libraries in parallel.
// If the footprints are already in the cache, ReadFootprintFiles() will return
// immediately.
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
MList.ReadFootprintFiles( aTable, libName.length() ? &libName : nullptr, &progressReporter );
progressReporter.Show( false );
if( MList.GetErrorCount() )
MList.DisplayErrors( this );
if( dlg.IsKeyword() ) // Selection by keywords
{ {
allowWildSeach = false; // While SelectFootprint() can load a library at a time (and stop when a match
keys = moduleName; // is found), the async loader gives much better feedback and loads the libraries
moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable ); // in parallel.
// If the footprints are already in the cache, ReadFootprintFiles() will return
// immediately.
WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
MList.ReadFootprintFiles( aTable, libName.length() ? &libName : NULL, &progressReporter );
progressReporter.Show( false );
if( moduleName.IsEmpty() ) // Cancel command if( MList.GetErrorCount() )
MList.DisplayErrors( this );
if( dlg.IsKeyword() ) // Selection by keywords
{ {
m_canvas->MoveCursorToCrossHair(); allowWildSeach = false;
return NULL; keys = moduleName;
moduleName = SelectFootprint( this, libName, wxEmptyString, keys, aTable );
if( moduleName.IsEmpty() ) // Cancel command
{
m_canvas->MoveCursorToCrossHair();
return NULL;
}
} }
} else // Selection wild card
else if( moduleName.Contains( wxT( "?" ) )
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
{
allowWildSeach = false;
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
if( moduleName.IsEmpty() )
{ {
m_canvas->MoveCursorToCrossHair(); allowWildSeach = false;
return NULL; // Cancel command. moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString, aTable );
if( moduleName.IsEmpty() )
{
m_canvas->MoveCursorToCrossHair();
return NULL; // Cancel command.
}
} }
} }