47 info.m_parentName = aParentName;
48 info.m_isPower = aIsPower;
49 info.m_symbol.reset( aSymbol );
50 info.m_existsInDest =
false;
51 info.m_checked =
false;
52 info.m_autoSelected =
false;
62 info.m_existsInDest = aExistsFunc(
name );
74 if( !
info.m_parentName.IsEmpty() )
85 std::vector<wxString> names;
89 names.push_back(
name );
98 return ( it !=
m_symbols.end() ) ? &it->second :
nullptr;
105 return ( it !=
m_symbols.end() ) ? &it->second :
nullptr;
111 std::set<wxString> ancestors;
112 wxString current = aSymbolName;
118 if( it ==
m_parentMap.end() || it->second.IsEmpty() )
121 wxString parent = it->second;
126 ancestors.insert( parent );
136 std::set<wxString> descendants;
137 std::vector<wxString> toProcess = { aSymbolName };
139 while( !toProcess.empty() )
141 wxString current = toProcess.back();
142 toProcess.pop_back();
148 for(
const wxString& child : it->second )
150 if( descendants.find( child ) == descendants.end() )
152 descendants.insert( child );
153 toProcess.push_back( child );
166 return ( it !=
m_parentMap.end() ) ? it->second : wxString();
184 return it !=
m_parentMap.end() && !it->second.IsEmpty();
191 std::vector<wxString> changedSymbols;
196 return changedSymbols;
200 info->m_checked =
true;
201 info->m_autoSelected =
false;
204 std::set<wxString> ancestors =
GetAncestors( aSymbolName );
206 for(
const wxString& ancestor : ancestors )
213 changedSymbols.push_back( ancestor );
219 info->m_checked =
false;
220 info->m_autoSelected =
false;
226 if(
name != aSymbolName )
227 changedSymbols.push_back(
name );
231 return changedSymbols;
237 std::vector<wxString> selectedDescendants;
240 for(
const wxString& desc : descendants )
245 selectedDescendants.push_back( desc );
248 return selectedDescendants;
258 info->m_checked =
false;
259 info->m_autoSelected =
false;
264 for(
const wxString& desc : descendants )
283 if( !aFilter || aFilter(
name ) )
285 info.m_checked =
true;
286 info.m_autoSelected =
false;
298 if( !aFilter || aFilter(
name ) )
300 info.m_checked =
false;
301 info.m_autoSelected =
false;
311 std::vector<wxString>
result;
315 if(
info.m_checked ||
info.m_autoSelected )
343 if(
info.m_autoSelected && !
info.m_checked )
353 std::vector<wxString> conflicts;
357 if( (
info.m_checked ||
info.m_autoSelected ) &&
info.m_existsInDest )
358 conflicts.push_back(
name );
367 if( aFilter.IsEmpty() )
370 return aSymbolName.Lower().Contains( aFilter.Lower() );
378 info.m_autoSelected =
false;
387 for(
const wxString& ancestor : ancestors )
391 if( ancestorInfo && !ancestorInfo->
m_checked )
Define a library symbol object.
std::function< bool(const wxString &symbolName)> SYMBOL_EXISTS_FUNC
Callback type for checking if a symbol exists in the destination library.
void DeselectWithDescendants(const wxString &aSymbolName)
Force deselection of a symbol and all its descendants.
std::vector< wxString > GetConflicts() const
Get list of symbols that will conflict (selected and exist in destination).
void CheckExistingSymbols(SYMBOL_EXISTS_FUNC aExistsFunc)
Mark symbols that exist in the destination library.
std::map< wxString, wxString > m_parentMap
Map from symbol name to its parent name (for derived symbols)
void SelectAll(std::function< bool(const wxString &)> aFilter=nullptr)
Select all symbols (optionally filtered).
std::vector< wxString > GetDirectDerivatives(const wxString &aSymbolName) const
Get direct children (derivatives) of a symbol.
wxString GetParent(const wxString &aSymbolName) const
Get the direct parent of a symbol.
int GetManualSelectionCount() const
Get count of manually selected symbols.
std::map< wxString, SYMBOL_IMPORT_INFO > m_symbols
All symbols available for import, keyed by name.
void DeselectAll(std::function< bool(const wxString &)> aFilter=nullptr)
Deselect all symbols (optionally filtered).
void AddSymbol(const wxString &aName, const wxString &aParentName, bool aIsPower, LIB_SYMBOL *aSymbol=nullptr)
Add a symbol to the import list.
std::vector< wxString > GetSelectedDescendants(const wxString &aSymbolName) const
Get selected descendants that would be orphaned if a symbol is deselected.
std::vector< wxString > SetSymbolSelected(const wxString &aSymbolName, bool aSelected)
Set the selection state of a symbol.
std::vector< wxString > GetSymbolNames() const
Get all symbol names.
static bool MatchesFilter(const wxString &aSymbolName, const wxString &aFilter)
Check if a symbol name matches a filter string (case-insensitive contains).
int GetAutoSelectionCount() const
Get count of auto-selected symbols (dependencies).
void Clear()
Clear all loaded symbols and reset state.
void recalculateAutoSelections()
Recalculate auto-selection state for all symbols based on current manual selections.
SYMBOL_IMPORT_INFO * GetSymbolInfo(const wxString &aName)
Get symbol info by name.
std::map< wxString, std::vector< wxString > > m_derivativesMap
Map from parent name to list of direct derivative names.
bool IsDerived(const wxString &aSymbolName) const
Check if a symbol is derived from another.
std::set< wxString > GetAncestors(const wxString &aSymbolName) const
Get all ancestors of a symbol (full inheritance chain).
std::set< wxString > GetDescendants(const wxString &aSymbolName) const
Get all descendants of a symbol (all derived symbols recursively).
std::vector< wxString > GetSymbolsToImport() const
Get list of all symbols that will be imported (checked + auto-selected).
void BuildDependencyMaps()
Build the dependency maps from parent relationships.
Information about a symbol available for import.
bool m_checked
User's manual selection state.
bool m_autoSelected
True if auto-selected as dependency.
wxString result
Test unit parsing edge cases and error handling.