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>
107 return wxString::FromUTF8(
"☆ " );
180 void DoAddLibrary(
const wxString& aNodeName,
const wxString& aDesc,
181 const std::vector<LIB_TREE_ITEM*>& aItemList,
182 bool pinned,
bool presorted );
218 void AttachTo( wxDataViewCtrl* aDataViewCtrl );
226 void OnSize( wxSizeEvent& aEvent );
246 int GetUnitFor(
const wxDataViewItem& aSelection )
const;
288 unsigned int GetChildren(
const wxDataViewItem& aItem,
289 wxDataViewItemArray& aChildren )
const override;
341 bool IsContainer(
const wxDataViewItem& aItem )
const override;
348 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override;
355 wxString
GetColumnType(
unsigned int aCol )
const override {
return "string"; }
365 const wxDataViewItem& aItem,
366 unsigned int aCol )
const override;
373 const wxDataViewItem& aItem,
374 unsigned int aCol )
override {
return false; }
384 bool GetAttr(
const wxDataViewItem& aItem,
386 wxDataViewItemAttr& aAttr )
const override;
415 wxDataViewColumn*
doAddColumn(
const wxString& aHeader,
bool aTranslate =
true );
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
The base frame for deriving all KiCad main window classes.
A logical library item identifier and consists of various portions much like a URI.
wxString GetColumnType(unsigned int aCol) const override
Return the type of data stored in the column as indicated by wxVariant::GetType()
int GetUnitFor(const wxDataViewItem &aSelection) const
Return the unit for the given item.
LIB_ID m_preselect_lib_id
LIB_TREE_NODE::TYPE GetTypeFor(const wxDataViewItem &aSelection) const
Return node type for the given item.
bool GetAttr(const wxDataViewItem &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
Get any formatting for an item.
LIB_TREE_NODE_ROOT m_tree
std::map< wxString, int > m_colWidths
void FinishTreeInitialization()
A final-stage initialization to be called after the window hierarchy has been realized and the window...
void AddColumn(const wxString &aHeader)
void addColumnIfNecessary(const wxString &aHeader)
void PinLibrary(LIB_TREE_NODE *aTreeNode)
void OnSize(wxSizeEvent &aEvent)
virtual TOOL_INTERACTIVE * GetContextMenuTool()
LIB_TREE_NODE_LIB & DoAddLibraryNode(const wxString &aNodeName, const wxString &aDesc, bool pinned)
virtual wxString GenerateInfo(const LIB_ID &aLibId, int aUnit)
void SetPreselectNode(const LIB_ID &aLibId, int aUnit)
Set the symbol name to be selected if there are no search results.
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
LIB_ID GetAliasFor(const wxDataViewItem &aSelection) const
Return the alias for the given item.
~LIB_TREE_MODEL_ADAPTER()
Destructor.
void AttachTo(wxDataViewCtrl *aDataViewCtrl)
Attach to a wxDataViewCtrl and initialize it.
void DoAddLibrary(const wxString &aNodeName, const wxString &aDesc, const std::vector< LIB_TREE_ITEM * > &aItemList, bool pinned, bool presorted)
Add the given list of symbols by alias.
void SetShownColumns(const std::vector< wxString > &aColumnNames)
Sets which columns are shown in the widget.
static wxDataViewItem ToItem(const LIB_TREE_NODE *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
void SetFilter(SYM_FILTER_TYPE aFilter)
Set the symbol filter type.
virtual bool isSymbolModel()=0
bool IsContainer(const wxDataViewItem &aItem) const override
Check whether an item can have children.
static const wxString GetPinningSymbol()
void AssignIntrinsicRanks()
Sort the tree and assign ranks after adding libraries.
SYM_FILTER_TYPE GetFilter() const
Return the active filter.
void Find(LIB_TREE_NODE &aNode, std::function< bool(const LIB_TREE_NODE *)> aFunc, LIB_TREE_NODE **aHighScore)
Find any results worth highlighting and expand them, according to given criteria The highest-scoring ...
void ShowUnits(bool aShow)
Whether or not to show units.
LIB_TREE_NODE * GetTreeNodeFor(const wxDataViewItem &aSelection) const
unsigned int GetChildren(const wxDataViewItem &aItem, wxDataViewItemArray &aChildren) const override
Populate a list of all the children of an item.
void SaveSettings()
Save the column widths to the config file.
TREE_COLS
This enum defines the order of the default columns in the tree view.
@ NUM_COLS
The number of default tree columns.
@ NAME_COL
Library or library item name column.
@ DESC_COL
Library or library description column.
std::map< unsigned, wxString > m_colIdxMap
wxDataViewColumn * doAddColumn(const wxString &aHeader, bool aTranslate=true)
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, const wxString &aPinnedKey)
Create the adapter.
LIB_TREE_NODE * ShowPreselect()
Find and expand preselected node.
std::vector< wxDataViewColumn * > m_columns
virtual int GetLibrariesCount() const
Return the number of libraries loaded in the tree.
std::vector< wxString > GetShownColumns() const
wxDataViewCtrl * m_widget
int GetItemCount() const
Return the number of symbols loaded in the tree.
std::vector< wxString > m_shownColumns
void GetValue(wxVariant &aVariant, const wxDataViewItem &aItem, unsigned int aCol) const override
Get the value of an item.
void UnpinLibrary(LIB_TREE_NODE *aTreeNode)
LIB_TREE_NODE * ShowSingleLibrary()
Find and expand a library if there is only one.
std::map< wxString, wxDataViewColumn * > m_colNameMap
bool HasContainerColumns(const wxDataViewItem &aItem) const override
Check whether a container has columns too.
bool SetValue(const wxVariant &aVariant, const wxDataViewItem &aItem, unsigned int aCol) override
Set the value of an item.
wxDataViewItem GetParent(const wxDataViewItem &aItem) const override
Get the parent of an item.
std::vector< wxString > m_availableColumns
unsigned int GetColumnCount() const override
EDA_BASE_FRAME * m_parent
static unsigned int IntoArray(const LIB_TREE_NODE &aNode, wxDataViewItemArray &aChildren)
Convert SYM_TREE_NODE's children to wxDataViewItemArray.
LIB_TREE_NODE * ShowResults()
Find and expand successful search results.
std::vector< wxString > GetAvailableColumns() const
wxDataViewItem FindItem(const LIB_ID &aLibId)
Returns tree item corresponding to part.
void UpdateSearchString(const wxString &aSearch, bool aState)
Set the search string provided by the user.
SYM_FILTER_TYPE
This enum allows a selective filtering of symbols to list.
@ SYM_FILTER_NONE
no filtering
@ SYM_FILTER_POWER
list symbols flagged PWR
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.