22 #ifndef LIB_TREE_MODEL_ADAPTER_H 23 #define LIB_TREE_MODEL_ADAPTER_H 27 #include <wx/hashmap.h> 28 #include <wx/dataview.h> 29 #include <wx/headerctrl.h> 169 void DoAddLibrary( wxString
const& aNodeName, wxString
const& aDesc,
170 std::vector<LIB_TREE_ITEM*>
const& aItemList,
bool presorted );
192 void AttachTo( wxDataViewCtrl* aDataViewCtrl );
219 int GetUnitFor(
const wxDataViewItem& aSelection )
const;
261 unsigned int GetChildren( wxDataViewItem
const& aItem,
262 wxDataViewItemArray& aChildren )
const override;
298 bool IsContainer( wxDataViewItem
const& aItem )
const override;
305 wxDataViewItem
GetParent( wxDataViewItem
const& aItem )
const override;
312 wxString
GetColumnType(
unsigned int aCol )
const override {
return "string"; }
322 wxDataViewItem
const& aItem,
323 unsigned int aCol )
const override;
330 wxDataViewItem
const& aItem,
331 unsigned int aCol )
override {
return false; }
341 bool GetAttr( wxDataViewItem
const& aItem,
343 wxDataViewItemAttr& aAttr )
const override;
352 return wxString::FromUTF8(
"☆ " );
399 #endif // LIB_TREE_MODEL_ADAPTER_H list components flagged PWR
~LIB_TREE_MODEL_ADAPTER()
Destructor.
void DoAddLibrary(wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_TREE_ITEM * > const &aItemList, bool presorted)
Add the given list of components by alias.
void AssignIntrinsicRanks()
Sort the tree and assign ranks after adding libraries.
bool IsContainer(wxDataViewItem const &aItem) const override
Check whether an item can have children.
CMP_FILTER_TYPE
This enum allows a selective filtering of components to list.
virtual int GetLibrariesCount() const
Return the number of libraries loaded in the tree.
wxDataViewColumn * m_col_desc
int GetUnitFor(const wxDataViewItem &aSelection) const
Return the unit for the given item.
void SetPreselectNode(LIB_ID const &aLibId, int aUnit)
Set the component name to be selected if there are no search results.
The number of tree columns.
EDA_BASE_FRAME * m_parent
LIB_TREE_NODE * ShowResults()
Find and expand successful search results.
LIB_TREE_NODE::TYPE GetTypeFor(const wxDataViewItem &aSelection) const
Return node type for the given item.
LIB_TREE_NODE * ShowPreselect()
Find and expand preselected node.
unsigned int GetColumnCount() const override
wxString GetColumnType(unsigned int aCol) const override
Return the type of data stored in the column as indicated by wxVariant::GetType()
A logical library item identifier and consists of various portions much like a URI.
virtual wxString GenerateInfo(LIB_ID const &aLibId, int aUnit)
static wxDataViewItem ToItem(LIB_TREE_NODE const *aNode)
Convert CMP_TREE_NODE -> wxDataViewItem.
LIB_TREE_NODE * GetTreeNodeFor(const wxDataViewItem &aSelection) const
static unsigned int IntoArray(LIB_TREE_NODE const &aNode, wxDataViewItemArray &aChildren)
Convert CMP_TREE_NODE's children to wxDataViewItemArray.
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
Get any formatting for an item.
int GetItemCount() const
Return the number of components loaded in the tree.
bool HasContainerColumns(wxDataViewItem const &aItem) const override
Check whether a container has columns too.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
void FindAndExpand(LIB_TREE_NODE &aNode, std::function< bool(LIB_TREE_NODE const *)> aFunc, LIB_TREE_NODE **aHighScore)
Find any results worth highlighting and expand them, according to given criteria The highest-scoring ...
void FinishTreeInitialization()
A final-stage initialization to be called after the window hierarchy has been realized and the window...
void SetFilter(CMP_FILTER_TYPE aFilter)
Set the component filter type.
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> CMP_TREE_NODE.
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
Get the parent of an item.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
LIB_TREE_NODE_LIB & DoAddLibraryNode(wxString const &aNodeName, wxString const &aDesc)
void UpdateSearchString(wxString const &aSearch, bool aState)
Set the search string provided by the user.
int m_colWidths[NUM_COLS]
virtual TOOL_INTERACTIVE * GetContextMenuTool()
TREE_COLS
This enum defines the order of the columns in the tree view.
LIB_ID GetAliasFor(const wxDataViewItem &aSelection) const
Return the alias for the given item.
const wxString GetPinningSymbol() const
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Get the value of an item.
wxDataViewCtrl * m_widget
bool SetValue(wxVariant const &aVariant, wxDataViewItem const &aItem, unsigned int aCol) override
Set the value of an item.
The base frame for deriving all KiCad main window classes.
LIB_ID m_preselect_lib_id
wxArrayString m_pinnedLibs
wxDataViewItem FindItem(const LIB_ID &aLibId)
Returns tree item corresponding to part.
wxDataViewColumn * m_col_part
LIB_TREE_NODE_ROOT m_tree
LIB_TREE_NODE * ShowSingleLibrary()
Find and expand a library if there is only one.
void SaveColWidths()
Save the column widths to the config file.
unsigned int GetChildren(wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
Populate a list of all the children of an item.
void AttachTo(wxDataViewCtrl *aDataViewCtrl)
Attach to a wxDataViewCtrl and initialize it.
CMP_FILTER_TYPE GetFilter() const
Return the active filter.
void ShowUnits(bool aShow)
Whether or not to show units.
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, wxString aPinnedKey)
Creates the adapter.