KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIB_TREE_NODE_ITEM Class Reference

Node type: LIB_ID. More...

#include <lib_tree_model.h>

Inheritance diagram for LIB_TREE_NODE_ITEM:
LIB_TREE_NODE

Public Types

enum  TYPE {
  ROOT , LIBRARY , ITEM , UNIT ,
  INVALID
}
 
typedef std::vector< std::unique_ptr< LIB_TREE_NODE > > PTR_VECTOR
 

Public Member Functions

 LIB_TREE_NODE_ITEM (LIB_TREE_NODE_ITEM const &_)=delete
 The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be copied around.
 
void operator= (LIB_TREE_NODE_ITEM const &_)=delete
 
 LIB_TREE_NODE_ITEM (LIB_TREE_NODE *aParent, LIB_TREE_ITEM *aItem)
 Construct a LIB_ID node.
 
void Update (LIB_TREE_ITEM *aItem)
 Update the node using data from a LIB_ALIAS object.
 
void UpdateScore (EDA_COMBINED_MATCHER *aMatcher, const wxString &aLib, std::function< bool(LIB_TREE_NODE &aNode)> *aFilter) override
 Perform the actual search.
 
virtual void ResetScore ()
 Initialize scores recursively.
 
virtual void ForceScore (int aScore)
 
void AssignIntrinsicRanks (bool presorted=false)
 Store intrinsic ranks on all children of this node.
 
void SortNodes (bool aUseScores)
 Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
 

Static Public Member Functions

static bool Compare (LIB_TREE_NODE const &aNode1, LIB_TREE_NODE const &aNode2, bool aUseScores)
 Compare two nodes.
 

Public Attributes

LIB_TREE_NODEm_Parent
 
PTR_VECTOR m_Children
 
enum TYPE m_Type
 
int m_IntrinsicRank
 The rank of the item before any search terms are applied.
 
int m_Score
 
bool m_Pinned
 
wxString m_Name
 
wxString m_Desc
 
wxString m_Footprint
 
int m_PinCount
 
std::vector< SEARCH_TERMm_SearchTerms
 
std::map< wxString, wxString > m_Fields
 List of weighted search terms.
 
LIB_ID m_LibId
 
int m_Unit
 
bool m_IsRoot
 

Protected Member Functions

LIB_TREE_NODE_UNITAddUnit (LIB_TREE_ITEM *aItem, int aUnit)
 Add a new unit to the component and return it.
 

Detailed Description

Node type: LIB_ID.

Definition at line 186 of file lib_tree_model.h.

Member Typedef Documentation

◆ PTR_VECTOR

typedef std::vector<std::unique_ptr<LIB_TREE_NODE> > LIB_TREE_NODE::PTR_VECTOR
inherited

Definition at line 123 of file lib_tree_model.h.

Member Enumeration Documentation

◆ TYPE

enum LIB_TREE_NODE::TYPE
inherited
Enumerator
ROOT 
LIBRARY 
ITEM 
UNIT 
INVALID 

Definition at line 114 of file lib_tree_model.h.

Constructor & Destructor Documentation

◆ LIB_TREE_NODE_ITEM() [1/2]

LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM ( LIB_TREE_NODE_ITEM const &  _)
delete

The addresses of CMP_TREE_NODEs are used as unique IDs for the wxDataViewModel, so don't let them be copied around.

◆ LIB_TREE_NODE_ITEM() [2/2]

LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM ( LIB_TREE_NODE aParent,
LIB_TREE_ITEM aItem 
)

Construct a LIB_ID node.

All fields will be populated from the LIB_ALIAS, including children (unit nodes will be generated automatically). This does not keep the pointer to the #LIB_ALIAS object because at any time, a #LIB_ALIAS can be remove from a library which will result in an invalid pointer. The alias must be resolved at the time of use. Anything else is a bug.

Parameters
aParentparent node, should be a CMP_TREE_NODE_LIB
aItemLIB_COMPONENT to populate the node.

Definition at line 190 of file lib_tree_model.cpp.

References AddUnit(), LIB_TREE_ITEM::GetChooserFields(), LIB_TREE_ITEM::GetDesc(), LIB_TREE_ITEM::GetFootprint(), LIB_TREE_ITEM::GetLibNickname(), LIB_TREE_ITEM::GetName(), LIB_TREE_ITEM::GetPinCount(), LIB_TREE_ITEM::GetSearchTerms(), LIB_TREE_ITEM::GetSubUnitCount(), LIB_TREE_ITEM::IsRoot(), LIB_TREE_NODE::ITEM, LIB_TREE_NODE::m_Desc, LIB_TREE_NODE::m_Fields, LIB_TREE_NODE::m_Footprint, LIB_TREE_NODE::m_IsRoot, LIB_TREE_NODE::m_LibId, LIB_TREE_NODE::m_Name, LIB_TREE_NODE::m_Parent, LIB_TREE_NODE::m_PinCount, LIB_TREE_NODE::m_SearchTerms, LIB_TREE_NODE::m_Type, LIB_ID::SetLibItemName(), and LIB_ID::SetLibNickname().

Member Function Documentation

◆ AddUnit()

LIB_TREE_NODE_UNIT & LIB_TREE_NODE_ITEM::AddUnit ( LIB_TREE_ITEM aItem,
int  aUnit 
)
protected

Add a new unit to the component and return it.

This should not be used directly, as the constructor adds all units.

Definition at line 217 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Children.

Referenced by LIB_TREE_NODE_ITEM(), and Update().

◆ AssignIntrinsicRanks()

◆ Compare()

bool LIB_TREE_NODE::Compare ( LIB_TREE_NODE const &  aNode1,
LIB_TREE_NODE const &  aNode2,
bool  aUseScores 
)
staticinherited

Compare two nodes.

Returns true if aNode1 < aNode2.

Definition at line 83 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_IntrinsicRank, LIB_TREE_NODE::m_Name, LIB_TREE_NODE::m_Pinned, LIB_TREE_NODE::m_Score, and LIB_TREE_NODE::m_Type.

◆ ForceScore()

virtual void LIB_TREE_NODE::ForceScore ( int  aScore)
inlinevirtualinherited

Definition at line 92 of file lib_tree_model.h.

References LIB_TREE_NODE::m_Score.

◆ operator=()

void LIB_TREE_NODE_ITEM::operator= ( LIB_TREE_NODE_ITEM const &  _)
delete

◆ ResetScore()

void LIB_TREE_NODE::ResetScore ( )
virtualinherited

Initialize scores recursively.

Definition at line 33 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Children, and LIB_TREE_NODE::m_Score.

Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().

◆ SortNodes()

void LIB_TREE_NODE::SortNodes ( bool  aUseScores)
inherited

Sort child nodes quickly and recursively (IntrinsicRanks must have been set).

Definition at line 70 of file lib_tree_model.cpp.

References LIB_TREE_NODE::m_Children.

Referenced by LIB_TREE_MODEL_ADAPTER::resortTree(), and LIB_TREE_MODEL_ADAPTER::UpdateSearchString().

◆ Update()

◆ UpdateScore()

void LIB_TREE_NODE_ITEM::UpdateScore ( EDA_COMBINED_MATCHER aMatcher,
const wxString &  aLib,
std::function< bool(LIB_TREE_NODE &aNode)> *  aFilter 
)
overridevirtual

Member Data Documentation

◆ m_Children

◆ m_Desc

◆ m_Fields

std::map<wxString, wxString> LIB_TREE_NODE::m_Fields
inherited

List of weighted search terms.

Definition at line 145 of file lib_tree_model.h.

Referenced by LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_ITEM(), and Update().

◆ m_Footprint

wxString LIB_TREE_NODE::m_Footprint
inherited

Definition at line 141 of file lib_tree_model.h.

Referenced by LIB_TREE_NODE_ITEM(), and PANEL_SYMBOL_CHOOSER::onSymbolSelected().

◆ m_IntrinsicRank

int LIB_TREE_NODE::m_IntrinsicRank
inherited

The rank of the item before any search terms are applied.

This is a fairly expensive sort (involving string compares) so it helps to store the result of that sort.

Definition at line 134 of file lib_tree_model.h.

Referenced by LIB_TREE_NODE::AssignIntrinsicRanks(), LIB_TREE_NODE::Compare(), and LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT().

◆ m_IsRoot

bool LIB_TREE_NODE::m_IsRoot
inherited

◆ m_LibId

◆ m_Name

◆ m_Parent

◆ m_PinCount

int LIB_TREE_NODE::m_PinCount
inherited

◆ m_Pinned

◆ m_Score

◆ m_SearchTerms

std::vector<SEARCH_TERM> LIB_TREE_NODE::m_SearchTerms
inherited

◆ m_Type

◆ m_Unit


The documentation for this class was generated from the following files: