![]() |
KiCad PCB EDA Suite
|
Model class in the component selector Model-View-Adapter (mediated MVC) architecture. More...
#include <lib_tree_model.h>
Public Types | |
enum | TYPE { ROOT, LIB, LIBID, UNIT, INVALID } |
typedef std::vector< std::unique_ptr< LIB_TREE_NODE > > | PTR_VECTOR |
Public Member Functions | |
virtual void | UpdateScore (EDA_COMBINED_MATCHER &aMatcher, const wxString &aLib)=0 |
Update the score for this part. More... | |
void | ResetScore () |
Initialize score to kLowestDefaultScore, recursively. More... | |
void | AssignIntrinsicRanks (bool presorted=false) |
Store intrinsic ranks on all children of this node. More... | |
void | SortNodes () |
Sort child nodes quickly and recursively (IntrinsicRanks must have been set). More... | |
LIB_TREE_NODE () | |
virtual | ~LIB_TREE_NODE () |
Static Public Member Functions | |
static int | Compare (LIB_TREE_NODE const &aNode1, LIB_TREE_NODE const &aNode2) |
Compare two nodes. More... | |
Public Attributes | |
LIB_TREE_NODE * | m_Parent |
PTR_VECTOR | m_Children |
enum TYPE | m_Type |
int | m_IntrinsicRank |
The rank of the item before any search terms are applied. More... | |
int | m_Score |
bool | m_Pinned |
wxString | m_Name |
wxString | m_Desc |
wxString | m_MatchName |
wxString | m_SearchText |
bool | m_Normalized |
LIB_ID | m_LibId |
int | m_Unit |
bool | m_IsRoot |
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
The other pieces are in:
This model is populated from LIB_ALIASes; helper methods in the adapter can accept entire libraries.
Quick summary of methods used to populate this class:
CMP_TREE_NODE_ROOT::AddLib()
- add a new, empty library to the rootCMP_TREE_NODE_LIB::AddAlias()
- add an alias and its units from a given LIB_ALIAS*Quick summary of methods used to drive this class:
UpdateScore()
- accumulate scores recursively given a new search tokenResetScore()
- reset scores recursively for a new search stringAssignIntrinsicRanks()
- calculate and cache the initial sort orderSortNodes()
- recursively sort the tree by scoreCompare()
- compare two nodes; used by SortNodes()
The data in the model is meant to be accessed directly. Quick summary of data members:
Parent
- parent node, or nullptr if rootChildren
- vector of unique_ptrs to childrenType
- ROOT, LIB, ALIAS, or UNITm_IntrinsicRank
- cached initial sort orderm_Score
- score taking into account search terms. Zero means irrelevant and should be hidden.Name
- name of the library/alias/unit, to be displayedDesc
- description of the alias, to be displayedm_MatchName
- Name, normalized to lowercase for matchingm_SearchText
- normalized composite of keywords and descriptionLibId
- the LIB_ID this alias or unit is from, or not validUnit
- the unit number, or zero for non-units Definition at line 75 of file lib_tree_model.h.
typedef std::vector<std::unique_ptr<LIB_TREE_NODE> > LIB_TREE_NODE::PTR_VECTOR |
Definition at line 115 of file lib_tree_model.h.
enum LIB_TREE_NODE::TYPE |
Enumerator | |
---|---|
ROOT | |
LIB | |
LIBID | |
UNIT | |
INVALID |
Definition at line 111 of file lib_tree_model.h.
LIB_TREE_NODE::LIB_TREE_NODE | ( | ) |
Definition at line 118 of file lib_tree_model.cpp.
|
inlinevirtual |
Definition at line 109 of file lib_tree_model.h.
void LIB_TREE_NODE::AssignIntrinsicRanks | ( | bool | presorted = false | ) |
Store intrinsic ranks on all children of this node.
See m_IntrinsicRank member doc for more information.
Definition at line 62 of file lib_tree_model.cpp.
References m_Children, m_IntrinsicRank, m_Name, and StrNumCmp().
Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), LIB_TREE_MODEL_ADAPTER::AssignIntrinsicRanks(), LIB_TREE_MODEL_ADAPTER::DoAddLibrary(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary().
|
static |
Compare two nodes.
Returns negative if aNode1 < aNode2, zero if aNode1 == aNode2, or positive if aNode1 > aNode2.
Definition at line 103 of file lib_tree_model.cpp.
References m_IntrinsicRank, m_Parent, m_Score, and m_Type.
Referenced by SortNodes().
void LIB_TREE_NODE::ResetScore | ( | ) |
Initialize score to kLowestDefaultScore, recursively.
Definition at line 53 of file lib_tree_model.cpp.
References kLowestDefaultScore, m_Children, and m_Score.
Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().
void LIB_TREE_NODE::SortNodes | ( | ) |
Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
Definition at line 90 of file lib_tree_model.cpp.
References Compare(), and m_Children.
Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().
|
pure virtual |
Update the score for this part.
This is accumulative - it will be called once per search term.
aMatcher | an EDA_COMBINED_MATCHER initialized with the search term |
Implemented in LIB_TREE_NODE_ROOT, LIB_TREE_NODE_LIB, LIB_TREE_NODE_LIB_ID, and LIB_TREE_NODE_UNIT.
PTR_VECTOR LIB_TREE_NODE::m_Children |
Definition at line 118 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_LIB::AddItem(), LIB_TREE_NODE_ROOT::AddLib(), LIB_TREE_NODE_LIB_ID::AddUnit(), AssignIntrinsicRanks(), FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), LIB_TREE_MODEL_ADAPTER::FindAndExpand(), LIB_TREE_MODEL_ADAPTER::FindItem(), LIB_TREE_MODEL_ADAPTER::GetItemCount(), LIB_TREE_MODEL_ADAPTER::GetLibrariesCount(), LIB_TREE_MODEL_ADAPTER::IntoArray(), LIB_TREE_MODEL_ADAPTER::IsContainer(), ResetScore(), LIB_TREE_MODEL_ADAPTER::SavePinnedItems(), LIB_TREE_MODEL_ADAPTER::ShowPreselect(), LIB_TREE_MODEL_ADAPTER::ShowSingleLibrary(), SortNodes(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), LIB_TREE_NODE_LIB_ID::Update(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), LIB_TREE_NODE_LIB::UpdateScore(), LIB_TREE_NODE_ROOT::UpdateScore(), and LIB_TREE_MODEL_ADAPTER::UpdateSearchString().
wxString LIB_TREE_NODE::m_Desc |
Definition at line 132 of file lib_tree_model.h.
Referenced by SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_MODEL_ADAPTER::GetValue(), LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), and LIB_TREE_NODE_LIB_ID::Update().
int LIB_TREE_NODE::m_IntrinsicRank |
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 126 of file lib_tree_model.h.
Referenced by AssignIntrinsicRanks(), Compare(), and LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT().
bool LIB_TREE_NODE::m_IsRoot |
Definition at line 140 of file lib_tree_model.h.
Referenced by SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetAttr(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), and LIB_TREE_NODE_LIB_ID::Update().
LIB_ID LIB_TREE_NODE::m_LibId |
Definition at line 138 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode(), LIB_TREE_MODEL_ADAPTER::GetAliasFor(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_MODEL_ADAPTER::ShowPreselect(), and LIB_TREE_NODE_LIB_ID::Update().
wxString LIB_TREE_NODE::m_MatchName |
Definition at line 133 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_NODE_LIB_ID::UpdateScore(), and LIB_TREE_NODE_LIB::UpdateScore().
wxString LIB_TREE_NODE::m_Name |
Definition at line 131 of file lib_tree_model.h.
Referenced by AssignIntrinsicRanks(), FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_MODEL_ADAPTER::GetValue(), LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary().
bool LIB_TREE_NODE::m_Normalized |
Definition at line 135 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_LIB_ID::Update(), and LIB_TREE_NODE_LIB_ID::UpdateScore().
LIB_TREE_NODE* LIB_TREE_NODE::m_Parent |
Definition at line 117 of file lib_tree_model.h.
Referenced by LIB_TREE::centerIfValid(), Compare(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetParent(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_MODEL_ADAPTER::ShowPreselect(), LIB_TREE_MODEL_ADAPTER::ShowSingleLibrary(), and LIB_TREE_NODE_LIB_ID::UpdateScore().
bool LIB_TREE_NODE::m_Pinned |
Definition at line 129 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SYMBOL_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::PinLibrary(), SYMBOL_EDITOR_CONTROL::PinLibrary(), FOOTPRINT_EDITOR_CONTROL::UnpinLibrary(), and SYMBOL_EDITOR_CONTROL::UnpinLibrary().
int LIB_TREE_NODE::m_Score |
Definition at line 128 of file lib_tree_model.h.
Referenced by Compare(), ResetScore(), LIB_TREE_MODEL_ADAPTER::ShowResults(), LIB_TREE_NODE_LIB_ID::UpdateScore(), and LIB_TREE_NODE_LIB::UpdateScore().
wxString LIB_TREE_NODE::m_SearchText |
Definition at line 134 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_LIB_ID::Update(), and LIB_TREE_NODE_LIB_ID::UpdateScore().
enum TYPE LIB_TREE_NODE::m_Type |
Definition at line 119 of file lib_tree_model.h.
Referenced by Compare(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetChildren(), LIB_TREE_MODEL_ADAPTER::GetParent(), LIB_TREE_MODEL_ADAPTER::GetTypeFor(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SYMBOL_EDITOR_CONTROL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), FP_TREE_SYNCHRONIZING_ADAPTER::IsContainer(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::IsContainer(), LIB_TREE_NODE_LIB::LIB_TREE_NODE_LIB(), LIB_TREE_NODE_LIB_ID::LIB_TREE_NODE_LIB_ID(), LIB_TREE_NODE_ROOT::LIB_TREE_NODE_ROOT(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_MODEL_ADAPTER::ShowPreselect(), LIB_TREE_MODEL_ADAPTER::ShowResults(), and LIB_TREE_MODEL_ADAPTER::ShowSingleLibrary().
int LIB_TREE_NODE::m_Unit |
Definition at line 139 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::GetUnitFor(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), and LIB_TREE_MODEL_ADAPTER::ShowPreselect().