23#ifndef LIB_TREE_MODEL_ADAPTER_H
24#define LIB_TREE_MODEL_ADAPTER_H
29#include <wx/hashmap.h>
30#include <wx/dataview.h>
31#include <wx/headerctrl.h>
111 return wxString::FromUTF8(
"☆ " );
183 void DoAddLibrary(
const wxString& aNodeName,
const wxString& aDesc,
184 const std::vector<LIB_TREE_ITEM*>& aItemList,
185 bool pinned,
bool presorted );
199 void OpenLibs(
const std::vector<wxString>& aLibs );
226 void AttachTo( wxDataViewCtrl* aDataViewCtrl );
253 int GetUnitFor(
const wxDataViewItem& aSelection )
const;
269 virtual bool HasPreview(
const wxDataViewItem& aItem ) {
return false; }
270 virtual void ShowPreview( wxWindow* aParent,
const wxDataViewItem& aItem ) {}
302 unsigned int GetChildren(
const wxDataViewItem& aItem,
303 wxDataViewItemArray& aChildren )
const override;
357 bool IsContainer(
const wxDataViewItem& aItem )
const override;
364 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override;
371 wxString
GetColumnType(
unsigned int aCol )
const override {
return "string"; }
381 const wxDataViewItem& aItem,
382 unsigned int aCol )
const override;
389 const wxDataViewItem& aItem,
390 unsigned int aCol )
override {
return false; }
400 bool GetAttr(
const wxDataViewItem& aItem,
402 wxDataViewItemAttr& aAttr )
const override;
414 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()
std::vector< wxString > GetOpenLibs() const
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.
void SetSortMode(SORT_MODE aMode)
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 addColumnIfNecessary(const wxString &aHeader)
void PinLibrary(LIB_TREE_NODE *aTreeNode)
virtual PROJECT::LIB_TYPE_T getLibType()=0
virtual TOOL_INTERACTIVE * GetContextMenuTool()
virtual wxString GenerateInfo(const LIB_ID &aLibId, int aUnit)
virtual wxDataViewItem GetCurrentDataViewItem()
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.
TOOL_DISPATCHER * GetToolDispatcher() const
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.
SORT_MODE GetSortMode() const
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.
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.
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::function< bool(LIB_TREE_NODE &aNode)> * GetFilter() const
Return the active filter.
std::map< unsigned, wxString > m_colIdxMap
wxDataViewColumn * doAddColumn(const wxString &aHeader, bool aTranslate=true)
virtual bool HasPreview(const wxDataViewItem &aItem)
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.
void ShowChangedLanguage()
const LIB_TREE_NODE * ShowResults()
Find and expand successful search results.
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)
void DoRemoveLibrary(const wxString &aNodeName)
Remove the library by name.
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.
LIB_TREE_NODE_LIBRARY & DoAddLibraryNode(const wxString &aNodeName, const wxString &aDesc, bool pinned)
std::vector< wxString > m_availableColumns
unsigned int GetColumnCount() const override
EDA_BASE_FRAME * m_parent
std::vector< wxString > GetAvailableColumns() const
virtual void ShowPreview(wxWindow *aParent, const wxDataViewItem &aItem)
void SetFilter(std::function< bool(LIB_TREE_NODE &aNode)> *aFilter)
Set the symbol filter type.
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.
std::function< bool(LIB_TREE_NODE &aNode)> * m_filter
APP_SETTINGS_BASE * m_cfg
void OpenLibs(const std::vector< wxString > &aLibs)
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.
Base window classes and related definitions.