27#include <wx/tokenzr.h>
36wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
42 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
50 Kiface().KifaceSettings()->m_DesignBlockChooserPanel.tree ),
53 m_contextMenuTool( aContextMenuTool )
93 const wxString& aLibName )
95 std::vector<LIB_TREE_ITEM*> libList;
100 std::unique_ptr<DESIGN_BLOCK_INFO>
dummy = std::make_unique<DESIGN_BLOCK_INFO_IMPL>( aLibName, wxEmptyString );
103 auto libBounds = std::equal_range(
104 fullListStart, fullListEnd,
dummy,
105 [](
const std::unique_ptr<DESIGN_BLOCK_INFO>& a,
const std::unique_ptr<DESIGN_BLOCK_INFO>& b )
107 return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(),
false ) < 0;
110 for(
auto i = libBounds.first; i != libBounds.second; ++i )
111 libList.push_back( i->get() );
123 "<hr><table border=0>"
127 static const wxString
DescFormat = wxS(
"<br>%s" );
128 static const wxString
KeywordsFormat = wxS(
"<br>" ) +
_(
"Keywords" ) + wxS(
": %s" );
132 " <td><b>__FIELD_NAME__</b></td>"
133 " <td>__FIELD_VALUE__</td>"
138 return wxEmptyString;
148 wxLogError(
_(
"Error loading design block %s from library '%s'." ) + wxS(
"\n%s" ),
151 return wxEmptyString;
167 esc_desc.Replace( wxS(
"\n" ), wxS(
"<br>" ) );
172 if( esc_desc.IsEmpty() )
173 html.Replace(
"__DESC__", wxEmptyString );
175 html.Replace(
"__DESC__", wxString::Format(
DescFormat, esc_desc ) );
177 if( keywords.IsEmpty() )
178 html.Replace(
"__KEY__", wxEmptyString );
184 for(
const auto& [key, value] : db->
GetFields() )
187 fieldRow.Replace( wxS(
"__FIELD_NAME__" ),
EscapeHTML( key ) );
188 fieldRow.Replace( wxS(
"__FIELD_VALUE__" ),
EscapeHTML( value ) );
189 fieldTable += fieldRow;
192 html.Replace(
"__FIELDS__", fieldTable );
196 html.Printf(
_(
"Error loading design block %s from library '%s'." ) + wxS(
"\n" ),
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Hold a record identifying a library accessed by the appropriate design block library #PLUGIN object i...
const DESIGN_BLOCK * GetEnumeratedDesignBlock(const wxString &aNickname, const wxString &aDesignBlockName)
A version of DesignBlockLoad() for use after DesignBlockEnumerate() for more efficient cache manageme...
static DESIGN_BLOCK_LIST_IMPL & GetGlobalList()
const DESIGN_BLOCK_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an DESIGN_BLOCK_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back ...
const std::vector< std::unique_ptr< DESIGN_BLOCK_INFO > > & GetList() const
Was forced to add this by modview_frame.cpp.
std::vector< LIB_TREE_ITEM * > getDesignBlocks(EDA_BASE_FRAME *aParent, const wxString &aLibName)
DESIGN_BLOCK_LIB_TABLE * m_libs
wxString GenerateInfo(LIB_ID const &aLibId, int aUnit) override
void AddLibraries(EDA_BASE_FRAME *aParent)
TOOL_INTERACTIVE * GetContextMenuTool() override
TOOL_INTERACTIVE * m_contextMenuTool
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs, APP_SETTINGS_BASE::LIB_TREE &aSettings, TOOL_INTERACTIVE *aContextMenuTool)
Factory function: create a model adapter in a reference-counting container.
DESIGN_BLOCK_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs, APP_SETTINGS_BASE::LIB_TREE &aSettings, TOOL_INTERACTIVE *aContextMenuTool)
Constructor; takes a set of libraries to be included in the search.
const wxString & GetKeywords() const
const wxString & GetLibDescription() const
const nlohmann::ordered_map< wxString, wxString > & GetFields() const
The base frame for deriving all KiCad main window classes.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
A logical library item identifier and consists of various portions much like a URI.
bool IsValid() const
Check if this LID_ID is valid.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
LIB_TREE_NODE_ROOT m_tree
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.
void Clear()
Clear the tree.
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
virtual PROJECT_FILE & GetProjectFile() const
Base window classes and related definitions.
Abstract pattern-matching tool and implementations.
static const wxString KeywordsFormat
static const wxString DescriptionFormat
static const wxString DescFormat
static const wxString FieldFormat
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< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
wxString UnescapeString(const wxString &aSource)
wxString LinkifyHTML(wxString aStr)
Wraps links in HTML tags.
std::vector< wxString > pinned_design_block_libs