25#include <wx/tokenzr.h>
41wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
45 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
68 for(
const std::pair<const wxString, int>& pair :
m_cfg.column_widths )
86 std::unordered_set<wxString> pinned;
88 std::ranges::copy(
project.m_PinnedSymbolLibs, std::inserter( pinned, pinned.begin() ) );
91 [&](
const wxString& aLibName,
const std::vector<LIB_SYMBOL*>& aSymbolList,
92 const wxString& aDescription )
108 std::vector<wxString> toLoad;
119 if( row->Disabled() || row->Hidden() )
122 toLoad.emplace_back( row->Nickname() );
126 for(
const wxString& lib : toLoad )
128 std::optional<LIB_STATUS> status =
m_adapter->GetLibraryStatus( lib );
138 wxCHECK2( rowResult,
continue );
140 wxString libDescription = ( *rowResult )->Description();
142 std::vector<LIB_SYMBOL*> libSymbols =
m_adapter->GetSymbols( lib );
144 for(
const wxString& column :
m_adapter->GetAvailableExtraFields( lib ) )
147 if(
m_adapter->SupportsSubLibraries( lib ) )
149 for(
const auto& [nickname, description] :
m_adapter->GetSubLibraries( lib ) )
151 wxString suffix = lib.IsEmpty() ? wxString( wxT(
"" ) )
152 : wxString::Format( wxT(
" - %s" ), nickname );
153 wxString
name = wxString::Format( wxT(
"%s%s" ), lib, suffix );
154 wxString desc = description;
156 if( !libDescription.IsEmpty() )
158 desc = wxString::Format( wxT(
"%s (%s)" ),
160 desc.IsEmpty() ? lib : desc );
163 UTF8 utf8Lib( nickname );
165 std::vector<LIB_SYMBOL*> symbols;
167 std::copy_if( libSymbols.begin(), libSymbols.end(),
168 std::back_inserter( symbols ),
171 return utf8Lib == aSym->GetLibId().GetSubLibraryName();
174 addFunc(
name, symbols, desc );
179 addFunc( lib, libSymbols, libDescription );
189 aFrame->Bind( wxEVT_TIMER,
190 [&, aFrame]( wxTimerEvent& )
220 std::vector<LIB_SYMBOL*> symbols =
m_adapter->GetSymbols( aLibNickname, type );
223 std::vector<LIB_TREE_ITEM*> comp_list;
225 if( row && symbols.size() > 0 )
227 comp_list.assign( symbols.begin(), symbols.end() );
228 DoAddLibrary( aLibNickname, ( *row )->Description(), comp_list, pinned,
false );
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
std::vector< LIBRARY_TABLE_ROW * > Rows(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH, bool aIncludeInvalid=false) const
Returns a flattened list of libraries of the given type.
std::optional< LIBRARY_TABLE_ROW * > GetRow(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH)
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, const wxString &aPinnedKey, APP_SETTINGS_BASE::LIB_TREE &aSettingsStruct)
Create the adapter.
void createMissingColumns()
APP_SETTINGS_BASE::LIB_TREE & m_cfg
LIB_TREE_NODE_ROOT m_tree
std::map< wxString, int > m_colWidths
void addColumnIfNecessary(const wxString &aHeader)
std::function< void()> m_lazyLoadHandler
std::function< bool(LIB_TREE_NODE &aNode)> * GetFilter() const
Return the active filter.
std::vector< wxString > m_shownColumns
LIB_TREE_NODE_LIBRARY & DoAddLibraryNode(const wxString &aNodeName, const wxString &aDesc, bool pinned)
std::vector< wxString > m_availableColumns
LIB_TREE_NODE_LIBRARY & DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
LIB_TREE_NODE_ITEM & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
void AssignIntrinsicRanks(const std::vector< wxString > &aShownColumns, bool presorted=false)
Store intrinsic ranks on all children of this node.
virtual COMMON_SETTINGS * GetCommonSettings() const
virtual LIBRARY_MANAGER & GetLibraryManager() const
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
An interface to the global shared library manager that is schematic-specific and linked to one projec...
wxString GenerateInfo(LIB_ID const &aLibId, int aUnit) override
void AddLibraries(SCH_BASE_FRAME *aFrame)
Add all the libraries in a SYMBOL_LIB_TABLE to the model.
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(SCH_BASE_FRAME *aParent, SYMBOL_LIBRARY_ADAPTER *aLibs)
Factory function: create a model adapter in a reference-counting container.
std::unique_ptr< wxTimer > m_check_pending_libraries_timer
void AddLibrary(wxString const &aLibNickname, bool pinned)
SYMBOL_LIBRARY_ADAPTER * m_adapter
std::set< wxString > m_pending_load_libraries
~SYMBOL_TREE_MODEL_ADAPTER()
Destructor.
void loadColumnConfig() override
SYMBOL_TREE_MODEL_ADAPTER(SCH_BASE_FRAME *aParent, SYMBOL_LIBRARY_ADAPTER *aManager)
Constructor; takes a set of libraries to be included in the search.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
wxString GenerateAliasInfo(SYMBOL_LIBRARY_ADAPTER *aLibs, LIB_ID const &aLibId, int aUnit)
Return an HTML page describing a LIB_ID in a #SYMBOL_LIB_TABLE.
const wxChar *const traceLibraries
Flag to enable library table and library manager tracing.
PGM_BASE & Pgm()
The global program "get" accessor.
std::vector< wxString > pinned_symbol_libs
wxString GetDefaultFieldName(FIELD_T aFieldId, bool aTranslateForHI)
Return a default symbol field name for a mandatory field type.
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ VALUE
Field Value of part, i.e. "3.3K".
wxLogTrace helper definitions.