Formatting and clearer variable names.
(No functional changes.)
This commit is contained in:
parent
a263b6d343
commit
e549d7c0c6
|
@ -78,9 +78,9 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
// Disable KIID generation: not needed for library parts; sometimes very slow
|
||||
KIID::CreateNilUuids( true );
|
||||
|
||||
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
|
||||
std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbolMap;
|
||||
|
||||
SYMBOL_ASYNC_LOADER loader( aNicknames, m_libs, GetFilter() != nullptr, &loadedSymbols,
|
||||
SYMBOL_ASYNC_LOADER loader( aNicknames, m_libs, GetFilter() != nullptr, &loadedSymbolMap,
|
||||
progressReporter.get() );
|
||||
|
||||
LOCALE_IO toggle;
|
||||
|
@ -115,7 +115,7 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
if( loadedSymbols.size() > 0 )
|
||||
if( loadedSymbolMap.size() > 0 )
|
||||
{
|
||||
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
|
||||
PROJECT_FILE& project = aFrame->Prj().GetProjectFile();
|
||||
|
@ -131,9 +131,9 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
DoAddLibrary( aLibName, aDescription, treeItems, pinned, false );
|
||||
};
|
||||
|
||||
for( const std::pair<const wxString, std::vector<LIB_SYMBOL*>>& pair : loadedSymbols )
|
||||
for( const auto& [libNickname, libSymbols] : loadedSymbolMap )
|
||||
{
|
||||
SYMBOL_LIB_TABLE_ROW* row = m_libs->FindRow( pair.first );
|
||||
SYMBOL_LIB_TABLE_ROW* row = m_libs->FindRow( libNickname );
|
||||
|
||||
wxCHECK2( row, continue );
|
||||
|
||||
|
@ -151,13 +151,13 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
std::vector<wxString> subLibraries;
|
||||
row->GetSubLibraryNames( subLibraries );
|
||||
|
||||
wxString parentDesc = m_libs->GetDescription( pair.first );
|
||||
wxString parentDesc = m_libs->GetDescription( libNickname );
|
||||
|
||||
for( const wxString& lib : subLibraries )
|
||||
{
|
||||
wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
|
||||
: wxString::Format( wxT( " - %s" ), lib );
|
||||
wxString name = wxString::Format( wxT( "%s%s" ), pair.first, suffix );
|
||||
wxString name = wxString::Format( wxT( "%s%s" ), libNickname, suffix );
|
||||
wxString desc;
|
||||
|
||||
if( !parentDesc.IsEmpty() )
|
||||
|
@ -165,7 +165,7 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
|
||||
std::vector<LIB_SYMBOL*> symbols;
|
||||
|
||||
std::copy_if( pair.second.begin(), pair.second.end(),
|
||||
std::copy_if( libSymbols.begin(), libSymbols.end(),
|
||||
std::back_inserter( symbols ),
|
||||
[&lib]( LIB_SYMBOL* aSym )
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
|
|||
}
|
||||
else
|
||||
{
|
||||
addFunc( pair.first, pair.second, m_libs->GetDescription( pair.first ) );
|
||||
addFunc( libNickname, libSymbols, m_libs->GetDescription( libNickname ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,32 +126,33 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
|||
std::vector<LIB_TREE_ITEM*> already_placed;
|
||||
|
||||
// Lambda to encapsulate the common logic
|
||||
auto processList = [&]( const std::vector<PICKED_SYMBOL>& inputList,
|
||||
std::vector<LIB_SYMBOL>& storageList,
|
||||
std::vector<LIB_TREE_ITEM*>& resultList )
|
||||
{
|
||||
storageList.reserve( inputList.size() );
|
||||
|
||||
for( const PICKED_SYMBOL& i : inputList )
|
||||
{
|
||||
LIB_SYMBOL* symbol = m_frame->GetLibSymbol( i.LibId );
|
||||
|
||||
if( symbol )
|
||||
auto processList =
|
||||
[&]( const std::vector<PICKED_SYMBOL>& inputList,
|
||||
std::vector<LIB_SYMBOL>& storageList,
|
||||
std::vector<LIB_TREE_ITEM*>& resultList )
|
||||
{
|
||||
storageList.emplace_back( *symbol );
|
||||
storageList.reserve( inputList.size() );
|
||||
|
||||
for( const std::pair<int, wxString>& fieldDef : i.Fields )
|
||||
for( const PICKED_SYMBOL& i : inputList )
|
||||
{
|
||||
LIB_FIELD* field = storageList.back().GetFieldById( fieldDef.first );
|
||||
LIB_SYMBOL* symbol = m_frame->GetLibSymbol( i.LibId );
|
||||
|
||||
if( field )
|
||||
field->SetText( fieldDef.second );
|
||||
if( symbol )
|
||||
{
|
||||
storageList.emplace_back( *symbol );
|
||||
|
||||
for( const std::pair<int, wxString>& fieldDef : i.Fields )
|
||||
{
|
||||
LIB_FIELD* field = storageList.back().GetFieldById( fieldDef.first );
|
||||
|
||||
if( field )
|
||||
field->SetText( fieldDef.second );
|
||||
}
|
||||
|
||||
resultList.push_back( &storageList.back() );
|
||||
}
|
||||
}
|
||||
|
||||
resultList.push_back( &storageList.back() );
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Sort the already placed list since it is potentially from multiple sessions,
|
||||
// but not the most recent list since we want this listed by most recent usage.
|
||||
|
|
Loading…
Reference in New Issue