25#include <wx/tokenzr.h>
41#define PROGRESS_INTERVAL_MILLIS 33
44wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
49 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
56 aParent->GetViewerSettingsBase()->m_LibTree ),
81 [&](
const wxString& aLibName,
const std::vector<LIB_SYMBOL*>& aSymbolList,
82 const wxString& aDescription )
84 std::vector<LIB_TREE_ITEM*> treeItems( aSymbolList.begin(), aSymbolList.end() );
88 DoAddLibrary( aLibName, aDescription, treeItems, pinned,
false );
93 std::vector<wxString> toLoad;
107 toLoad.emplace_back( row->Nickname() );
111 for(
const wxString& lib : toLoad )
113 if( !
m_adapter->GetLibraryStatus( lib ) )
119 std::optional<const LIBRARY_TABLE_ROW*> rowResult =
122 wxCHECK2( rowResult,
continue );
124 wxString libDescription = ( *rowResult )->Description();
126 std::vector<LIB_SYMBOL*> libSymbols =
m_adapter->GetSymbols( lib );
128 for(
const wxString& column :
m_adapter->GetAvailableExtraFields( lib ) )
131 if(
m_adapter->SupportsSubLibraries( lib ) )
133 for(
const auto& [nickname, description] :
m_adapter->GetSubLibraries( lib ) )
135 wxString suffix = lib.IsEmpty() ? wxString( wxT(
"" ) )
136 : wxString::Format( wxT(
" - %s" ), nickname );
137 wxString
name = wxString::Format( wxT(
"%s%s" ), lib, suffix );
138 wxString desc = description;
140 if( !libDescription.IsEmpty() )
142 desc = wxString::Format( wxT(
"%s (%s)" ),
144 desc.IsEmpty() ? lib : desc );
147 UTF8 utf8Lib( nickname );
149 std::vector<LIB_SYMBOL*> symbols;
151 std::copy_if( libSymbols.begin(), libSymbols.end(),
152 std::back_inserter( symbols ),
155 return utf8Lib == aSym->GetLibId().GetSubLibraryName();
158 addFunc(
name, symbols, desc );
163 addFunc( lib, libSymbols, libDescription );
171 wxLogTrace(
traceLibraries,
"%zu pending libraries, starting lazy load...",
174 aFrame->Bind( wxEVT_TIMER,
175 [&, aFrame]( wxTimerEvent& )
206 std::vector<LIB_SYMBOL*> symbols =
m_adapter->GetSymbols( aLibNickname, type );
207 std::vector<LIB_TREE_ITEM*> comp_list;
209 std::optional<const LIBRARY_TABLE_ROW*> row =
212 if( row && symbols.size() > 0 )
214 comp_list.assign( symbols.begin(), symbols.end() );
215 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) const
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, const wxString &aPinnedKey, APP_SETTINGS_BASE::LIB_TREE &aSettingsStruct)
Create the adapter.
void createMissingColumns()
LIB_TREE_NODE_ROOT m_tree
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
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.
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
static bool m_show_progress
Flag to only show the symbol library table load progress dialog the first time.
void AddLibrary(wxString const &aLibNickname, bool pinned)
SYMBOL_LIBRARY_ADAPTER * m_adapter
std::set< wxString > m_pending_load_libraries
~SYMBOL_TREE_MODEL_ADAPTER()
Destructor.
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.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
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".
@ DATASHEET
name of datasheet
@ VALUE
Field Value of part, i.e. "3.3K".
wxLogTrace helper definitions.