49 return ( aPosition < aMaximum ) ? aMaximum - aPosition : 0;
55 for( std::unique_ptr<LIB_TREE_NODE>& child:
m_Children )
64 std::vector<LIB_TREE_NODE*> sort_buf;
70 for(
int i = 0; i <= max; ++i )
75 for( std::unique_ptr<LIB_TREE_NODE>& child:
m_Children )
76 sort_buf.push_back( child.get() );
78 std::sort( sort_buf.begin(), sort_buf.end(),
81 return StrNumCmp( a->m_Name, b->m_Name, true ) > 0;
84 for(
int i = 0; i < (int) sort_buf.size(); ++i )
93 []( std::unique_ptr<LIB_TREE_NODE>& a, std::unique_ptr<LIB_TREE_NODE>& b )
95 return Compare( *a, *b ) > 0;
98 for( std::unique_ptr<LIB_TREE_NODE>& node:
m_Children )
109 if( aNode1.
m_Name.StartsWith( wxT(
"-- " ) ) )
111 else if( aNode2.
m_Name.StartsWith( wxT(
"-- " ) ) )
128 : m_Parent( nullptr ),
130 m_IntrinsicRank( 0 ),
133 m_Normalized( false ),
141 static void* locale =
nullptr;
142 static wxString namePrefix;
146 if(
Pgm().GetLocale() != locale )
148 namePrefix =
_(
"Unit" );
149 locale =
Pgm().GetLocale();
206 m_Children.push_back( std::unique_ptr<LIB_TREE_NODE>( unit ) );
255 int matchers_fired = 0;
295 wxString
const& aDesc )
309 m_Children.push_back( std::unique_ptr<LIB_TREE_NODE>( item ) );
322 for( std::unique_ptr<LIB_TREE_NODE>& child:
m_Children )
324 child->UpdateScore( aMatcher, aLib );
332 if( !aLib.IsEmpty() )
339 int matchers_fired = 0;
366 m_Children.push_back( std::unique_ptr<LIB_TREE_NODE>( lib ) );
373 for( std::unique_ptr<LIB_TREE_NODE>& child:
m_Children )
374 child->UpdateScore( aMatcher, aLib );
bool Find(const wxString &aTerm, int &aMatchersTriggered, int &aPosition)
const wxString & GetPattern() const
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
virtual wxString GetUnitReference(int aUnit)
For items with units, return an identifier for unit x.
virtual wxString GetLibNickname() const =0
virtual bool HasUnitDisplayName(int aUnit)
For items with units, return true if a display name is set for x.
virtual wxString GetFootprint()
For items with footprint fields.
virtual bool IsRoot() const
For items having aliases, IsRoot() indicates the principal item.
virtual wxString GetName() const =0
virtual wxString GetDescription()=0
virtual LIB_ID GetLibId() const =0
virtual wxString GetSearchText()
virtual int GetUnitCount() const
For items with units, return the number of units.
virtual wxString GetUnitDisplayName(int aUnit)
For items with units, return a display name for unit x.
virtual void GetChooserFields(std::map< wxString, wxString > &aColumnMap)
Retrieves a key/value map of the fields on this item that should be exposed to the library browser/ch...
LIB_TREE_NODE_UNIT & AddUnit(LIB_TREE_ITEM *aItem, int aUnit)
Add a new unit to the component and return it.
void Update(LIB_TREE_ITEM *aItem)
Update the node using data from a LIB_ALIAS object.
LIB_TREE_NODE_LIB_ID(LIB_TREE_NODE_LIB_ID const &_)=delete
The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be ...
virtual void UpdateScore(EDA_COMBINED_MATCHER &aMatcher, const wxString &aLib) override
Perform the actual search.
LIB_TREE_NODE_LIB_ID & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
LIB_TREE_NODE_LIB(LIB_TREE_NODE_LIB const &_)=delete
The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be ...
virtual void UpdateScore(EDA_COMBINED_MATCHER &aMatcher, const wxString &aLib) override
Update the score for this part.
virtual void UpdateScore(EDA_COMBINED_MATCHER &aMatcher, const wxString &aLib) override
Update the score for this part.
LIB_TREE_NODE_ROOT()
Construct the root node.
LIB_TREE_NODE_LIB & AddLib(wxString const &aName, wxString const &aDesc)
Construct an empty library node, add it to the root, and return it.
Node type: unit of component.
LIB_TREE_NODE_UNIT(LIB_TREE_NODE_UNIT const &_)=delete
The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be ...
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void SortNodes()
Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
std::map< wxString, wxString > m_Fields
void ResetScore()
Initialize score to kLowestDefaultScore, recursively.
int m_IntrinsicRank
The rank of the item before any search terms are applied.
static int Compare(LIB_TREE_NODE const &aNode1, LIB_TREE_NODE const &aNode2)
Compare two nodes.
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
Abstract pattern-matching tool and implementations.
static const int EDA_PATTERN_NOT_FOUND
static const unsigned kLowestDefaultScore
static int matchPosScore(int aPosition, int aMaximum)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString UnescapeString(const wxString &aSource)