KiCad PCB EDA Suite
|
#include <cmp_tree_model_adapter.h>
Public Types | |
enum | CMP_FILTER_TYPE { CMP_FILTER_NONE, CMP_FILTER_POWER } |
This enum allows a selective filtering of components to list. More... | |
typedef wxObjectDataPtr< CMP_TREE_MODEL_ADAPTER_BASE > | PTR |
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE. More... | |
Public Member Functions | |
~CMP_TREE_MODEL_ADAPTER () | |
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER. More... | |
void | AddLibrary (wxString const &aLibNickname) override |
Add all the components and their aliases in this library. More... | |
void | AddAliasList (wxString const &aNodeName, wxArrayString const &aAliasNameList) override |
Add the given list of components, by name. More... | |
void | SetFilter (CMP_FILTER_TYPE aFilter) |
Set the component filter type. More... | |
CMP_FILTER_TYPE | GetFilter () const |
Return the active filter. More... | |
void | ShowUnits (bool aShow) |
Whether or not to show units. More... | |
void | SetPreselectNode (LIB_ID const &aLibId, int aUnit) |
Set the component name to be selected if there are no search results. More... | |
void | AddLibrariesWithProgress (const std::vector< wxString > &aNicknames, wxWindow *aParent) |
Add all the libraries in a SYMBOL_LIB_TABLE to the model, displaying a progress dialog attached to the parent frame. More... | |
void | AddAliasList (wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_ALIAS * > const &aAliasList) |
Add the given list of components by alias. More... | |
void | UpdateSearchString (wxString const &aSearch) |
Set the search string provided by the user. More... | |
void | AttachTo (wxDataViewCtrl *aDataViewCtrl) |
Attach to a wxDataViewCtrl and initialize it. More... | |
LIB_ID | GetAliasFor (const wxDataViewItem &aSelection) const |
Return the alias for the given item. More... | |
int | GetUnitFor (const wxDataViewItem &aSelection) const |
Return the unit for the given item. More... | |
CMP_TREE_NODE::TYPE | GetTypeFor (const wxDataViewItem &aSelection) const |
Return node type for the given item. More... | |
int | GetComponentsCount () const |
Return the number of components loaded in the tree. More... | |
virtual int | GetLibrariesCount () const |
Return the number of libraries loaded in the tree. More... | |
wxDataViewItem | FindItem (const LIB_ID &aLibId) |
Returns tree item corresponding to part. More... | |
virtual unsigned int | GetChildren (wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override |
Populate a list of all the children of an item. More... | |
Static Public Member Functions | |
static PTR | Create (SYMBOL_LIB_TABLE *aLibs) |
Factory function: create a model adapter in a reference-counting container. More... | |
Protected Member Functions | |
CMP_TREE_MODEL_ADAPTER (SYMBOL_LIB_TABLE *aLibs) | |
Constructor; takes a set of libraries to be included in the search. More... | |
virtual bool | HasContainerColumns (wxDataViewItem const &aItem) const override |
Check whether a container has columns too. More... | |
virtual bool | IsContainer (wxDataViewItem const &aItem) const override |
Check whether an item can have children. More... | |
virtual wxDataViewItem | GetParent (wxDataViewItem const &aItem) const override |
Get the parent of an item. More... | |
virtual unsigned int | GetColumnCount () const override |
Return the number of columns in the model. More... | |
virtual wxString | GetColumnType (unsigned int aCol) const override |
Return the type of data stored in the column. More... | |
virtual void | GetValue (wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override |
Get the value of an item. More... | |
virtual bool | SetValue (wxVariant const &aVariant, wxDataViewItem const &aItem, unsigned int aCol) override |
Set the value of an item. More... | |
virtual bool | GetAttr (wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override |
Get any formatting for an item. More... | |
Static Protected Member Functions | |
static wxDataViewItem | ToItem (CMP_TREE_NODE const *aNode) |
Convert CMP_TREE_NODE -> wxDataViewItem. More... | |
static CMP_TREE_NODE const * | ToNode (wxDataViewItem aItem) |
Convert wxDataViewItem -> CMP_TREE_NODE. More... | |
static unsigned int | IntoArray (CMP_TREE_NODE const &aNode, wxDataViewItemArray &aChildren) |
Convert CMP_TREE_NODE's children to wxDataViewItemArray. More... | |
Protected Attributes | |
CMP_TREE_NODE_ROOT | m_tree |
Private Attributes | |
SYMBOL_LIB_TABLE * | m_libs |
Definition at line 29 of file cmp_tree_model_adapter.h.
|
inherited |
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
Definition at line 99 of file cmp_tree_model_adapter_base.h.
|
inherited |
This enum allows a selective filtering of components to list.
Enumerator | |
---|---|
CMP_FILTER_NONE |
no filtering |
CMP_FILTER_POWER |
list components flagged PWR |
Definition at line 110 of file cmp_tree_model_adapter_base.h.
CMP_TREE_MODEL_ADAPTER::~CMP_TREE_MODEL_ADAPTER | ( | ) |
Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER.
Destructor. Do NOT delete this class manually; it is reference-counted by wxObject.
Definition at line 42 of file cmp_tree_model_adapter.cpp.
|
protected |
Constructor; takes a set of libraries to be included in the search.
Definition at line 37 of file cmp_tree_model_adapter.cpp.
Referenced by Create().
|
overridevirtual |
Add the given list of components, by name.
To be called in the setup phase.
aNodeName | the parent node the components will appear under |
aAliasNameList | list of alias names |
Implements CMP_TREE_MODEL_ADAPTER_BASE.
Definition at line 71 of file cmp_tree_model_adapter.cpp.
References Format(), LIB_TABLE::GetDescription(), SYMBOL_LIB_TABLE::LoadSymbol(), m_libs, name, and IO_ERROR::What().
Referenced by AddLibrary().
|
inherited |
Add the given list of components by alias.
To be called in the setup phase.
aNodeName | the parent node the components will appear under |
aDesc | the description field of the parent node |
aAliasList | list of aliases |
Definition at line 146 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE_LIB::AddAlias(), CMP_TREE_NODE_ROOT::AddLib(), CMP_TREE_NODE::AssignIntrinsicRanks(), and CMP_TREE_MODEL_ADAPTER_BASE::m_tree.
|
inherited |
Add all the libraries in a SYMBOL_LIB_TABLE to the model, displaying a progress dialog attached to the parent frame.
aNicknames | is the list of library nicknames |
aParent | is the parent window to display the progress dialog |
Definition at line 112 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::AddLibrary(), Format(), CMP_TREE_MODEL_ADAPTER_BASE::m_show_progress, and PROGRESS_INTERVAL_MILLIS.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
overridevirtual |
Add all the components and their aliases in this library.
To be called in the setup phase.
aLibNickname | reference to a symbol library nickname |
Implements CMP_TREE_MODEL_ADAPTER_BASE.
Definition at line 46 of file cmp_tree_model_adapter.cpp.
References AddAliasList(), CMP_TREE_NODE::AssignIntrinsicRanks(), CMP_TREE_MODEL_ADAPTER_BASE::CMP_FILTER_POWER, Format(), LIB_TABLE::GetDescription(), CMP_TREE_MODEL_ADAPTER_BASE::GetFilter(), SYMBOL_LIB_TABLE::LoadSymbolLib(), m_libs, CMP_TREE_MODEL_ADAPTER_BASE::m_tree, and IO_ERROR::What().
|
inherited |
Attach to a wxDataViewCtrl and initialize it.
This will set up columns and associate the model via the adapter.
aDataViewCtrl | the view component in the dialog |
Definition at line 199 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ColWidth(), kDataViewIndent, CMP_TREE_MODEL_ADAPTER_BASE::m_col_desc, CMP_TREE_MODEL_ADAPTER_BASE::m_col_part, CMP_TREE_MODEL_ADAPTER_BASE::m_tree, and CMP_TREE_MODEL_ADAPTER_BASE::m_widget.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter(), and CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString().
|
static |
Factory function: create a model adapter in a reference-counting container.
aLibs | library set from which parts will be loaded |
Definition at line 29 of file cmp_tree_model_adapter.cpp.
References CMP_TREE_MODEL_ADAPTER().
Referenced by LIB_VIEW_FRAME::OnSelectSymbol(), and SCH_BASE_FRAME::SelectComponentFromLibrary().
|
inherited |
Returns tree item corresponding to part.
aLibId | specifies the part and library name to be searched for. |
Definition at line 260 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE::Children, LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), CMP_TREE_MODEL_ADAPTER_BASE::m_tree, and CMP_TREE_MODEL_ADAPTER_BASE::ToItem().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount().
|
inherited |
Return the alias for the given item.
aSelection | item from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection()) |
Definition at line 216 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
overrideprotectedvirtualinherited |
Get any formatting for an item.
aItem | item to get formatting for |
aCol | column number of interest |
aAttr | receiver for attributes |
Reimplemented in LIB_MANAGER_ADAPTER.
Definition at line 350 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE::LIBID, and CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::SetValue().
|
overridevirtualinherited |
Populate a list of all the children of an item.
Definition at line 284 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::IntoArray(), CMP_TREE_MODEL_ADAPTER_BASE::m_show_units, CMP_TREE_MODEL_ADAPTER_BASE::m_tree, and CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount().
|
inlineoverrideprotectedvirtualinherited |
Return the number of columns in the model.
Definition at line 296 of file cmp_tree_model_adapter_base.h.
|
inlineoverrideprotectedvirtualinherited |
Return the type of data stored in the column.
Definition at line 303 of file cmp_tree_model_adapter_base.h.
References CMP_TREE_MODEL_ADAPTER_BASE::GetValue().
|
inherited |
Return the number of components loaded in the tree.
Definition at line 243 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE::Children, and CMP_TREE_MODEL_ADAPTER_BASE::m_tree.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
inlineinherited |
Return the active filter.
Definition at line 126 of file cmp_tree_model_adapter_base.h.
References CMP_TREE_MODEL_ADAPTER_BASE::AddAliasList(), CMP_TREE_MODEL_ADAPTER_BASE::AddLibrariesWithProgress(), CMP_TREE_MODEL_ADAPTER_BASE::AddLibrary(), CMP_TREE_MODEL_ADAPTER_BASE::AttachTo(), CMP_TREE_MODEL_ADAPTER_BASE::GetAliasFor(), CMP_TREE_MODEL_ADAPTER_BASE::GetComponentsCount(), CMP_TREE_MODEL_ADAPTER_BASE::GetTypeFor(), CMP_TREE_MODEL_ADAPTER_BASE::GetUnitFor(), CMP_TREE_MODEL_ADAPTER_BASE::m_filter, CMP_TREE_MODEL_ADAPTER_BASE::SetPreselectNode(), CMP_TREE_MODEL_ADAPTER_BASE::ShowUnits(), and CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString().
Referenced by AddLibrary().
|
inlinevirtualinherited |
Return the number of libraries loaded in the tree.
Reimplemented in LIB_MANAGER_ADAPTER.
Definition at line 241 of file cmp_tree_model_adapter_base.h.
References CMP_TREE_NODE::Children, CMP_TREE_MODEL_ADAPTER_BASE::FindItem(), CMP_TREE_MODEL_ADAPTER_BASE::GetChildren(), CMP_TREE_MODEL_ADAPTER_BASE::IntoArray(), CMP_TREE_MODEL_ADAPTER_BASE::m_tree, CMP_TREE_MODEL_ADAPTER_BASE::ToItem(), and CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by LIB_MANAGER_ADAPTER::GetLibrariesCount().
|
overrideprotectedvirtualinherited |
Get the parent of an item.
aItem | item to get the parent of |
Definition at line 311 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ToItem(), and CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
|
inherited |
Return node type for the given item.
aSelection | item from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection()) |
Definition at line 236 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE::INVALID, and CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
inherited |
Return the unit for the given item.
aSelection | item from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection()) |
Definition at line 229 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
overrideprotectedvirtualinherited |
Get the value of an item.
aVariant | wxVariant to receive the data |
aItem | item whose data will be placed into aVariant |
aCol | column number of the data |
Reimplemented in LIB_MANAGER_ADAPTER.
Definition at line 329 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetColumnType().
|
overrideprotectedvirtualinherited |
Check whether a container has columns too.
Definition at line 298 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::IsContainer().
|
staticprotectedinherited |
Convert CMP_TREE_NODE's children to wxDataViewItemArray.
Definition at line 61 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_NODE::Children, and CMP_TREE_MODEL_ADAPTER_BASE::ToItem().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetChildren(), and CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount().
|
overrideprotectedvirtualinherited |
Check whether an item can have children.
Reimplemented in LIB_MANAGER_ADAPTER.
Definition at line 304 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::ToNode().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::HasContainerColumns().
|
inherited |
Set the component filter type.
Must be set before adding libraries
aFilter | if CMP_FILTER_POWER, only power parts are loaded |
Definition at line 93 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::m_filter.
|
inherited |
Set the component name to be selected if there are no search results.
May be set at any time; updates at the next UpdateSearchString().
aLibId | symbol LIB_ID to be selected |
aUnit | unit to be selected, if > 0 (0 selects the alias itself) |
Definition at line 105 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::m_preselect_lib_id, and CMP_TREE_MODEL_ADAPTER_BASE::m_preselect_unit.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
inlineoverrideprotectedvirtualinherited |
Set the value of an item.
Does nothing - this model doesn't support editing.
Definition at line 321 of file cmp_tree_model_adapter_base.h.
References CMP_TREE_MODEL_ADAPTER_BASE::GetAttr().
|
inherited |
Whether or not to show units.
May be set at any time; updates at the next UpdateSearchString()
aShow | if true, units are displayed |
Definition at line 99 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::m_show_units.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
staticprotectedinherited |
Convert CMP_TREE_NODE -> wxDataViewItem.
Definition at line 43 of file cmp_tree_model_adapter_base.cpp.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::FindItem(), CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount(), CMP_TREE_MODEL_ADAPTER_BASE::GetParent(), and CMP_TREE_MODEL_ADAPTER_BASE::IntoArray().
|
staticprotectedinherited |
Convert wxDataViewItem -> CMP_TREE_NODE.
Definition at line 52 of file cmp_tree_model_adapter_base.cpp.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetAliasFor(), LIB_MANAGER_ADAPTER::GetAttr(), CMP_TREE_MODEL_ADAPTER_BASE::GetAttr(), CMP_TREE_MODEL_ADAPTER_BASE::GetChildren(), CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount(), CMP_TREE_MODEL_ADAPTER_BASE::GetParent(), CMP_TREE_MODEL_ADAPTER_BASE::GetTypeFor(), CMP_TREE_MODEL_ADAPTER_BASE::GetUnitFor(), LIB_MANAGER_ADAPTER::GetValue(), CMP_TREE_MODEL_ADAPTER_BASE::GetValue(), LIB_MANAGER_ADAPTER::IsContainer(), and CMP_TREE_MODEL_ADAPTER_BASE::IsContainer().
|
inherited |
Set the search string provided by the user.
aSearch | full, unprocessed search text |
Definition at line 161 of file cmp_tree_model_adapter_base.cpp.
References CMP_TREE_MODEL_ADAPTER_BASE::AttachTo(), CMP_TREE_MODEL_ADAPTER_BASE::m_tree, CMP_TREE_MODEL_ADAPTER_BASE::m_widget, CMP_TREE_NODE::ResetScore(), CMP_TREE_MODEL_ADAPTER_BASE::ShowPreselect(), CMP_TREE_MODEL_ADAPTER_BASE::ShowResults(), CMP_TREE_MODEL_ADAPTER_BASE::ShowSingleLibrary(), CMP_TREE_NODE::SortNodes(), and CMP_TREE_NODE_ROOT::UpdateScore().
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::GetFilter().
|
private |
Definition at line 80 of file cmp_tree_model_adapter.h.
Referenced by AddAliasList(), and AddLibrary().
|
protectedinherited |
Definition at line 268 of file cmp_tree_model_adapter_base.h.
Referenced by CMP_TREE_MODEL_ADAPTER_BASE::AddAliasList(), AddLibrary(), CMP_TREE_MODEL_ADAPTER_BASE::AttachTo(), LIB_MANAGER_ADAPTER::deleteLibrary(), CMP_TREE_MODEL_ADAPTER_BASE::FindItem(), LIB_MANAGER_ADAPTER::findLibrary(), CMP_TREE_MODEL_ADAPTER_BASE::GetChildren(), CMP_TREE_MODEL_ADAPTER_BASE::GetComponentsCount(), CMP_TREE_MODEL_ADAPTER_BASE::GetLibrariesCount(), CMP_TREE_MODEL_ADAPTER_BASE::ShowPreselect(), CMP_TREE_MODEL_ADAPTER_BASE::ShowResults(), CMP_TREE_MODEL_ADAPTER_BASE::ShowSingleLibrary(), LIB_MANAGER_ADAPTER::Sync(), and CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString().