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 class | TYPE { ROOT , LIBRARY , ITEM , 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, std::function< bool(LIB_TREE_NODE &aNode)> *aFilter)=0 |
Update the score for this part. | |
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). | |
LIB_TREE_NODE () | |
virtual | ~LIB_TREE_NODE () |
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_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. | |
int | m_Score |
bool | m_Pinned |
wxString | m_Name |
wxString | m_Desc |
wxString | m_Footprint |
int | m_PinCount |
std::vector< SEARCH_TERM > | m_SearchTerms |
std::map< wxString, wxString > | m_Fields |
List of weighted search terms. | |
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 123 of file lib_tree_model.h.
|
strong |
Enumerator | |
---|---|
ROOT | |
LIBRARY | |
ITEM | |
UNIT | |
INVALID |
Definition at line 114 of file lib_tree_model.h.
LIB_TREE_NODE::LIB_TREE_NODE | ( | ) |
Definition at line 131 of file lib_tree_model.cpp.
|
inlinevirtual |
Definition at line 112 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 42 of file lib_tree_model.cpp.
References m_Children, and m_IntrinsicRank.
Referenced by SYMBOL_TREE_MODEL_ADAPTER::AddLibraries(), DESIGN_BLOCK_TREE_MODEL_ADAPTER::AddLibraries(), FP_TREE_MODEL_ADAPTER::AddLibraries(), LIB_TREE_MODEL_ADAPTER::AssignIntrinsicRanks(), LIB_TREE_MODEL_ADAPTER::DoAddLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), and FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary().
|
static |
Compare two nodes.
Returns true if aNode1 < aNode2.
Definition at line 83 of file lib_tree_model.cpp.
References m_IntrinsicRank, m_Name, m_Pinned, m_Score, and m_Type.
|
inlinevirtual |
Definition at line 92 of file lib_tree_model.h.
References m_Score.
|
virtual |
Initialize scores recursively.
Definition at line 33 of file lib_tree_model.cpp.
References m_Children, and m_Score.
Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().
void LIB_TREE_NODE::SortNodes | ( | bool | aUseScores | ) |
Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
Definition at line 70 of file lib_tree_model.cpp.
References m_Children.
Referenced by LIB_TREE_MODEL_ADAPTER::resortTree(), and 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_UNIT, LIB_TREE_NODE_ITEM, LIB_TREE_NODE_LIBRARY, and LIB_TREE_NODE_ROOT.
PTR_VECTOR LIB_TREE_NODE::m_Children |
Definition at line 126 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_LIBRARY::AddItem(), LIB_TREE_NODE_ROOT::AddLib(), LIB_TREE_NODE_ITEM::AddUnit(), AssignIntrinsicRanks(), LIB_TREE_NODE_ROOT::Clear(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), LIB_TREE_MODEL_ADAPTER::FindItem(), LIB_TREE_MODEL_ADAPTER::GetChildren(), LIB_TREE_MODEL_ADAPTER::GetItemCount(), LIB_TREE_MODEL_ADAPTER::GetLibrariesCount(), LIB_TREE_MODEL_ADAPTER::IsContainer(), recursiveDescent(), LIB_TREE_NODE_ROOT::RemoveLib(), ResetScore(), LIB_TREE_MODEL_ADAPTER::ShowResults(), SortNodes(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(), FP_TREE_SYNCHRONIZING_ADAPTER::Sync(), LIB_TREE_NODE_ITEM::Update(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), LIB_TREE_NODE_ITEM::UpdateScore(), LIB_TREE_NODE_LIBRARY::UpdateScore(), LIB_TREE_NODE_ROOT::UpdateScore(), and LIB_TREE_MODEL_ADAPTER::UpdateSearchString().
wxString LIB_TREE_NODE::m_Desc |
Definition at line 140 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), and LIB_TREE_NODE_ITEM::Update().
std::map<wxString, wxString> LIB_TREE_NODE::m_Fields |
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::LIB_TREE_NODE_ITEM(), and LIB_TREE_NODE_ITEM::Update().
wxString LIB_TREE_NODE::m_Footprint |
Definition at line 141 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), and PANEL_SYMBOL_CHOOSER::onSymbolSelected().
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 134 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 149 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::GetAttr(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), and LIB_TREE_NODE_ITEM::Update().
LIB_ID LIB_TREE_NODE::m_LibId |
Definition at line 147 of file lib_tree_model.h.
Referenced by SCH_DESIGN_BLOCK_CONTROL::DeleteDesignBlock(), SCH_DESIGN_BLOCK_CONTROL::EditDesignBlockProperties(), FOOTPRINT_CHOOSER_FRAME::filterFootprint(), LIB_TREE_MODEL_ADAPTER::GetAliasFor(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::HasPreview(), FP_TREE_SYNCHRONIZING_ADAPTER::HasPreview(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), PANEL_SYMBOL_CHOOSER::onSymbolSelected(), LIBRARY_EDITOR_CONTROL::PinLibrary(), SCH_DESIGN_BLOCK_CONTROL::PinLibrary(), LIB_TREE_MODEL_ADAPTER::PinLibrary(), SCH_DESIGN_BLOCK_CONTROL::SaveSelectionAsDesignBlock(), SCH_DESIGN_BLOCK_CONTROL::SaveSheetAsDesignBlock(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::ShowPreview(), FP_TREE_SYNCHRONIZING_ADAPTER::ShowPreview(), LIB_TREE_MODEL_ADAPTER::ShowResults(), LIBRARY_EDITOR_CONTROL::UnpinLibrary(), SCH_DESIGN_BLOCK_CONTROL::UnpinLibrary(), LIB_TREE_MODEL_ADAPTER::UnpinLibrary(), and LIB_TREE_NODE_ITEM::Update().
wxString LIB_TREE_NODE::m_Name |
Definition at line 139 of file lib_tree_model.h.
Referenced by Compare(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_MODEL_ADAPTER::ShowResults(), LIB_TREE_NODE_ITEM::Update(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), FP_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(), and LIB_TREE_NODE_LIBRARY::UpdateScore().
LIB_TREE_NODE* LIB_TREE_NODE::m_Parent |
Definition at line 125 of file lib_tree_model.h.
Referenced by LIB_TREE::centerIfValid(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetParent(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE_MODEL_ADAPTER::ShowResults(), and LIB_TREE_NODE_UNIT::UpdateScore().
int LIB_TREE_NODE::m_PinCount |
Definition at line 142 of file lib_tree_model.h.
Referenced by FOOTPRINT_CHOOSER_FRAME::filterFootprint(), and LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM().
bool LIB_TREE_NODE::m_Pinned |
Definition at line 137 of file lib_tree_model.h.
Referenced by LIBRARY_EDITOR_CONTROL::AddContextMenuItems(), Compare(), LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode(), LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SCH_DESIGN_BLOCK_CONTROL::Init(), LIB_TREE::onItemContextMenu(), LIBRARY_EDITOR_CONTROL::PinLibrary(), SCH_DESIGN_BLOCK_CONTROL::PinLibrary(), LIB_TREE_MODEL_ADAPTER::PinLibrary(), LIBRARY_EDITOR_CONTROL::UnpinLibrary(), SCH_DESIGN_BLOCK_CONTROL::UnpinLibrary(), and LIB_TREE_MODEL_ADAPTER::UnpinLibrary().
int LIB_TREE_NODE::m_Score |
Definition at line 136 of file lib_tree_model.h.
Referenced by Compare(), ForceScore(), ResetScore(), LIB_TREE_MODEL_ADAPTER::ShowResults(), LIB_TREE_NODE_UNIT::UpdateScore(), LIB_TREE_NODE_ITEM::UpdateScore(), and LIB_TREE_NODE_LIBRARY::UpdateScore().
std::vector<SEARCH_TERM> LIB_TREE_NODE::m_SearchTerms |
Definition at line 144 of file lib_tree_model.h.
Referenced by LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_ITEM::Update(), LIB_TREE_NODE_ITEM::UpdateScore(), and LIB_TREE_NODE_LIBRARY::UpdateScore().
enum TYPE LIB_TREE_NODE::m_Type |
Definition at line 127 of file lib_tree_model.h.
Referenced by LIBRARY_EDITOR_CONTROL::AddContextMenuItems(), Compare(), FOOTPRINT_CHOOSER_FRAME::filterFootprint(), LIB_TREE_MODEL_ADAPTER::GetAttr(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), FP_TREE_SYNCHRONIZING_ADAPTER::GetAttr(), LIB_TREE_MODEL_ADAPTER::GetChildren(), LIB_TREE_MODEL_ADAPTER::GetParent(), LIB_TREE_MODEL_ADAPTER::GetTypeFor(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::HasPreview(), FP_TREE_SYNCHRONIZING_ADAPTER::HasPreview(), SCH_DESIGN_BLOCK_CONTROL::Init(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::IsContainer(), FP_TREE_SYNCHRONIZING_ADAPTER::IsContainer(), LIB_TREE_NODE_ITEM::LIB_TREE_NODE_ITEM(), LIB_TREE_NODE_LIBRARY::LIB_TREE_NODE_LIBRARY(), LIB_TREE_NODE_ROOT::LIB_TREE_NODE_ROOT(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), LIB_TREE::onItemContextMenu(), and LIB_TREE_MODEL_ADAPTER::ShowResults().
int LIB_TREE_NODE::m_Unit |
Definition at line 148 of file lib_tree_model.h.
Referenced by LIB_TREE_MODEL_ADAPTER::GetUnitFor(), LIB_TREE_NODE_UNIT::LIB_TREE_NODE_UNIT(), PANEL_SYMBOL_CHOOSER::onSymbolSelected(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::ShowPreview(), and LIB_TREE_MODEL_ADAPTER::ShowResults().