KiCad PCB EDA Suite
SYMBOL_TREE_MODEL_ADAPTER Class Reference

#include <symbol_tree_model_adapter.h>

Inheritance diagram for SYMBOL_TREE_MODEL_ADAPTER:
LIB_TREE_MODEL_ADAPTER

Public Types

enum  SYM_FILTER_TYPE { SYM_FILTER_NONE, SYM_FILTER_POWER }
 This enum allows a selective filtering of symbols to list. More...
 
enum  TREE_COLS { PART_COL = 0, DESC_COL, NUM_COLS }
 This enum defines the order of the columns in the tree view. More...
 

Public Member Functions

 ~SYMBOL_TREE_MODEL_ADAPTER ()
 Destructor. More...
 
void AddLibraries (const std::vector< wxString > &aNicknames, wxWindow *aParent)
 Add all the libraries in a SYMBOL_LIB_TABLE to the model. More...
 
void AddLibrary (wxString const &aLibNickname)
 
wxString GenerateInfo (LIB_ID const &aLibId, int aUnit) override
 
void SaveColWidths ()
 Save the column widths to the config file. More...
 
void SavePinnedItems ()
 
void SetFilter (SYM_FILTER_TYPE aFilter)
 Set the symbol filter type. More...
 
SYM_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 symbol name to be selected if there are no search results. More...
 
void DoAddLibrary (wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_TREE_ITEM * > const &aItemList, bool presorted)
 Add the given list of symbols by alias. More...
 
void AssignIntrinsicRanks ()
 Sort the tree and assign ranks after adding libraries. More...
 
void UpdateSearchString (wxString const &aSearch, bool aState)
 Set the search string provided by the user. More...
 
void AttachTo (wxDataViewCtrl *aDataViewCtrl)
 Attach to a wxDataViewCtrl and initialize it. More...
 
void FinishTreeInitialization ()
 A final-stage initialization to be called after the window hierarchy has been realized and the window sizes set. 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...
 
LIB_TREE_NODE::TYPE GetTypeFor (const wxDataViewItem &aSelection) const
 Return node type for the given item. More...
 
LIB_TREE_NODEGetTreeNodeFor (const wxDataViewItem &aSelection) const
 
int GetItemCount () const
 Return the number of symbols 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...
 
unsigned int GetChildren (wxDataViewItem const &aItem, wxDataViewItemArray &aChildren) const override
 Populate a list of all the children of an item. More...
 
void Freeze ()
 
void Thaw ()
 
bool IsFrozen () const
 
void RefreshTree ()
 
virtual TOOL_INTERACTIVEGetContextMenuTool ()
 

Static Public Member Functions

static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTERCreate (EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
 Factory function: create a model adapter in a reference-counting container. More...
 

Protected Member Functions

 SYMBOL_TREE_MODEL_ADAPTER (EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
 Constructor; takes a set of libraries to be included in the search. More...
 
LIB_TREE_NODE_LIBDoAddLibraryNode (wxString const &aNodeName, wxString const &aDesc)
 
bool HasContainerColumns (wxDataViewItem const &aItem) const override
 Check whether a container has columns too. More...
 
bool IsContainer (wxDataViewItem const &aItem) const override
 Check whether an item can have children. More...
 
wxDataViewItem GetParent (wxDataViewItem const &aItem) const override
 Get the parent of an item. More...
 
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() More...
 
void GetValue (wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
 Get the value of an item. More...
 
bool SetValue (wxVariant const &aVariant, wxDataViewItem const &aItem, unsigned int aCol) override
 Set the value of an item. More...
 
bool GetAttr (wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
 Get any formatting for an item. More...
 
const wxString GetPinningSymbol () const
 

Static Protected Member Functions

static wxDataViewItem ToItem (LIB_TREE_NODE const *aNode)
 Convert #SYM_TREE_NODE -> wxDataViewItem. More...
 
static LIB_TREE_NODEToNode (wxDataViewItem aItem)
 Convert wxDataViewItem -> #SYM_TREE_NODE. More...
 
static unsigned int IntoArray (LIB_TREE_NODE const &aNode, wxDataViewItemArray &aChildren)
 Convert SYM_TREE_NODE's children to wxDataViewItemArray. More...
 

Protected Attributes

LIB_TREE_NODE_ROOT m_tree
 

Private Attributes

SYMBOL_LIB_TABLEm_libs
 

Static Private Attributes

static bool m_show_progress = true
 Flag to only show the symbol library table load progress dialog the first time. More...
 

Friends

class SYMBOL_ASYNC_LOADER
 

Detailed Description

Definition at line 30 of file symbol_tree_model_adapter.h.

Member Enumeration Documentation

◆ SYM_FILTER_TYPE

This enum allows a selective filtering of symbols to list.

Enumerator
SYM_FILTER_NONE 

no filtering

SYM_FILTER_POWER 

list symbols flagged PWR

Definition at line 109 of file lib_tree_model_adapter.h.

◆ TREE_COLS

This enum defines the order of the columns in the tree view.

Enumerator
PART_COL 

Part name column.

DESC_COL 

Part description column.

NUM_COLS 

The number of tree columns.

Definition at line 118 of file lib_tree_model_adapter.h.

119  {
120  PART_COL = 0,
121  DESC_COL,
122  NUM_COLS
123  };

Constructor & Destructor Documentation

◆ ~SYMBOL_TREE_MODEL_ADAPTER()

SYMBOL_TREE_MODEL_ADAPTER::~SYMBOL_TREE_MODEL_ADAPTER ( )

Destructor.

Do NOT delete this class manually; it is reference-counted by wxObject.

Definition at line 56 of file symbol_tree_model_adapter.cpp.

57 {}

◆ SYMBOL_TREE_MODEL_ADAPTER()

SYMBOL_TREE_MODEL_ADAPTER::SYMBOL_TREE_MODEL_ADAPTER ( EDA_BASE_FRAME aParent,
LIB_TABLE aLibs 
)
protected

Constructor; takes a set of libraries to be included in the search.

Definition at line 50 of file symbol_tree_model_adapter.cpp.

50  :
51  LIB_TREE_MODEL_ADAPTER( aParent, "pinned_symbol_libs" ),
52  m_libs( (SYMBOL_LIB_TABLE*) aLibs )
53 {}
LIB_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, wxString aPinnedKey)
Create the adapter.

Referenced by Create().

Member Function Documentation

◆ AddLibraries()

void SYMBOL_TREE_MODEL_ADAPTER::AddLibraries ( const std::vector< wxString > &  aNicknames,
wxWindow *  aParent 
)

Add all the libraries in a SYMBOL_LIB_TABLE to the model.

Displays a progress dialog attached to the parent frame the first time it is run.

Parameters
aNicknamesis the list of library nicknames
aParentis the parent window to display the progress dialog

Definition at line 60 of file symbol_tree_model_adapter.cpp.

62 {
63  std::unique_ptr<WX_PROGRESS_REPORTER> prg = nullptr;
64 
65  if( m_show_progress )
66  {
67  prg = std::make_unique<WX_PROGRESS_REPORTER>( aParent, _( "Loading Symbol Libraries" ),
68  aNicknames.size(), true );
69  }
70 
71  // Disable KIID generation: not needed for library parts; sometimes very slow
72  KIID::CreateNilUuids( true );
73 
74  std::unordered_map<wxString, std::vector<LIB_SYMBOL*>> loadedSymbols;
75 
76  SYMBOL_ASYNC_LOADER loader( aNicknames, m_libs,
78  &loadedSymbols, prg.get() );
79 
80  LOCALE_IO toggle;
81 
82  loader.Start();
83 
84  while( !loader.Done() )
85  {
86  if( prg )
87  prg->KeepRefreshing();
88 
89  wxMilliSleep( PROGRESS_INTERVAL_MILLIS );
90  }
91 
92  if( prg && prg->IsCancelled() )
93  {
94  loader.Abort();
95  }
96  else
97  {
98  loader.Join();
99  }
100 
101  if( !loader.GetErrors().IsEmpty() )
102  {
103  HTML_MESSAGE_BOX dlg( aParent, _( "Load Error" ) );
104 
105  dlg.MessageSet( _( "Errors were encountered loading symbols:" ) );
106 
107  wxString msg = loader.GetErrors();
108  msg.Replace( "\n", "<BR>" );
109 
110  dlg.AddHTML_Text( msg );
111  dlg.ShowModal();
112  }
113 
114  if( loadedSymbols.size() > 0 )
115  {
116  for( const std::pair<const wxString, std::vector<LIB_SYMBOL*>>& pair : loadedSymbols )
117  {
118  std::vector<LIB_TREE_ITEM*> treeItems( pair.second.begin(), pair.second.end() );
119  DoAddLibrary( pair.first, m_libs->GetDescription( pair.first ), treeItems, false );
120  }
121  }
122 
123  KIID::CreateNilUuids( false );
124 
126 
127  if( prg )
128  {
129  // Force immediate deletion of the APP_PROGRESS_DIALOG
130  // ( do not use Destroy(), or use Destroy() followed by wxSafeYield() )
131  // because on Windows, APP_PROGRESS_DIALOG has some side effects on the event loop
132  // manager. A side effect is the call of ShowModal() of a dialog following
133  // the use of SYMBOL_TREE_MODEL_ADAPTER creating a APP_PROGRESS_DIALOG
134  // has a broken behavior (incorrect modal behavior).
135  prg.reset();
136  m_show_progress = false;
137  }
138 }
void DoAddLibrary(wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_TREE_ITEM * > const &aItemList, bool presorted)
Add the given list of symbols by alias.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
SYM_FILTER_TYPE GetFilter() const
Return the active filter.
const wxString GetDescription(const wxString &aNickname)
#define _(s)
HTML_MESSAGE_BOX.
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.
static bool m_show_progress
Flag to only show the symbol library table load progress dialog the first time.
static void CreateNilUuids(bool aNil=true)
Definition: kiid.cpp:240
#define PROGRESS_INTERVAL_MILLIS

References _, HTML_MESSAGE_BOX::AddHTML_Text(), LIB_TREE_NODE::AssignIntrinsicRanks(), KIID::CreateNilUuids(), LIB_TREE_MODEL_ADAPTER::DoAddLibrary(), LIB_TABLE::GetDescription(), LIB_TREE_MODEL_ADAPTER::GetFilter(), m_libs, m_show_progress, LIB_TREE_MODEL_ADAPTER::m_tree, HTML_MESSAGE_BOX::MessageSet(), PROGRESS_INTERVAL_MILLIS, and LIB_TREE_MODEL_ADAPTER::SYM_FILTER_POWER.

◆ AddLibrary()

void SYMBOL_TREE_MODEL_ADAPTER::AddLibrary ( wxString const &  aLibNickname)

Definition at line 141 of file symbol_tree_model_adapter.cpp.

142 {
143  bool onlyPowerSymbols = ( GetFilter() == SYM_FILTER_POWER );
144  std::vector<LIB_SYMBOL*> symbols;
145  std::vector<LIB_TREE_ITEM*> comp_list;
146 
147  try
148  {
149  m_libs->LoadSymbolLib( symbols, aLibNickname, onlyPowerSymbols );
150  }
151  catch( const IO_ERROR& ioe )
152  {
153  wxLogError( wxString::Format( _( "Error loading symbol library %s.\n\n%s" ),
154  aLibNickname,
155  ioe.What() ) );
156  return;
157  }
158 
159  if( symbols.size() > 0 )
160  {
161  comp_list.assign( symbols.begin(), symbols.end() );
162  DoAddLibrary( aLibNickname, m_libs->GetDescription( aLibNickname ), comp_list, false );
163  }
164 }
void DoAddLibrary(wxString const &aNodeName, wxString const &aDesc, std::vector< LIB_TREE_ITEM * > const &aItemList, bool presorted)
Add the given list of symbols by alias.
SYM_FILTER_TYPE GetFilter() const
Return the active filter.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
const wxString GetDescription(const wxString &aNickname)
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void LoadSymbolLib(std::vector< LIB_SYMBOL * > &aAliasList, const wxString &aNickname, bool aPowerSymbolsOnly=false)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75

References _, LIB_TREE_MODEL_ADAPTER::DoAddLibrary(), Format(), LIB_TABLE::GetDescription(), LIB_TREE_MODEL_ADAPTER::GetFilter(), SYMBOL_LIB_TABLE::LoadSymbolLib(), m_libs, LIB_TREE_MODEL_ADAPTER::SYM_FILTER_POWER, and IO_ERROR::What().

◆ AssignIntrinsicRanks()

void LIB_TREE_MODEL_ADAPTER::AssignIntrinsicRanks ( )
inlineinherited

Sort the tree and assign ranks after adding libraries.

Definition at line 176 of file lib_tree_model_adapter.h.

void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.

References LIB_TREE_NODE::AssignIntrinsicRanks(), and LIB_TREE_MODEL_ADAPTER::m_tree.

◆ AttachTo()

void LIB_TREE_MODEL_ADAPTER::AttachTo ( wxDataViewCtrl *  aDataViewCtrl)
inherited

Attach to a wxDataViewCtrl and initialize it.

This will set up columns and associate the model via the adapter.

Parameters
aDataViewCtrlthe view symbol in the dialog

Definition at line 269 of file lib_tree_model_adapter.cpp.

270 {
271  wxString partHead = _( "Item" );
272  wxString descHead = _( "Description" );
273 
274  // The extent of the text doesn't take into account the space on either side
275  // in the header, so artificially pad it
276  wxSize partHeadMinWidth = KIUI::GetTextSize( partHead + "MMM", aDataViewCtrl );
277 
278  // Ensure the part column is wider than the smallest allowable width
279  if( m_colWidths[PART_COL] < partHeadMinWidth.x )
280  m_colWidths[PART_COL] = partHeadMinWidth.x;
281 
282  m_widget = aDataViewCtrl;
283  aDataViewCtrl->SetIndent( kDataViewIndent );
284  aDataViewCtrl->AssociateModel( this );
285  aDataViewCtrl->ClearColumns();
286 
287  m_col_part = aDataViewCtrl->AppendTextColumn( partHead, PART_COL, wxDATAVIEW_CELL_INERT,
289  m_col_desc = aDataViewCtrl->AppendTextColumn( descHead, DESC_COL, wxDATAVIEW_CELL_INERT,
291 
292  m_col_part->SetMinWidth( partHeadMinWidth.x );
293 }
static const int kDataViewIndent
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: ui_common.cpp:59
#define _(s)

References _, LIB_TREE_MODEL_ADAPTER::DESC_COL, KIUI::GetTextSize(), kDataViewIndent, LIB_TREE_MODEL_ADAPTER::m_col_desc, LIB_TREE_MODEL_ADAPTER::m_col_part, LIB_TREE_MODEL_ADAPTER::m_colWidths, LIB_TREE_MODEL_ADAPTER::m_widget, and LIB_TREE_MODEL_ADAPTER::PART_COL.

◆ Create()

wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > SYMBOL_TREE_MODEL_ADAPTER::Create ( EDA_BASE_FRAME aParent,
LIB_TABLE aLibs 
)
static

Factory function: create a model adapter in a reference-counting container.

Parameters
aLibslibrary set from which parts will be loaded

Definition at line 43 of file symbol_tree_model_adapter.cpp.

44 {
45  auto* adapter = new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs );
46  return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
47 }
SYMBOL_TREE_MODEL_ADAPTER(EDA_BASE_FRAME *aParent, LIB_TABLE *aLibs)
Constructor; takes a set of libraries to be included in the search.

References SYMBOL_TREE_MODEL_ADAPTER().

Referenced by SYMBOL_VIEWER_FRAME::OnSelectSymbol(), and SCH_BASE_FRAME::PickSymbolFromLibTree().

◆ DoAddLibrary()

void LIB_TREE_MODEL_ADAPTER::DoAddLibrary ( wxString const &  aNodeName,
wxString const &  aDesc,
std::vector< LIB_TREE_ITEM * > const &  aItemList,
bool  presorted 
)
inherited

Add the given list of symbols by alias.

To be called in the setup phase.

Parameters
aNodeNamethe parent node the symbols will appear under
aDescthe description field of the parent node
aItemListlist of symbols

Definition at line 168 of file lib_tree_model_adapter.cpp.

171 {
172  LIB_TREE_NODE_LIB& lib_node = DoAddLibraryNode( aNodeName, aDesc );
173 
174  for( LIB_TREE_ITEM* item: aItemList )
175  lib_node.AddItem( item );
176 
177  lib_node.AssignIntrinsicRanks( presorted );
178 }
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
Definition: lib_tree_item.h:38
LIB_TREE_NODE_LIB_ID & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
Node type: library.
LIB_TREE_NODE_LIB & DoAddLibraryNode(wxString const &aNodeName, wxString const &aDesc)
void AssignIntrinsicRanks(bool presorted=false)
Store intrinsic ranks on all children of this node.

References LIB_TREE_NODE_LIB::AddItem(), LIB_TREE_NODE::AssignIntrinsicRanks(), and LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode().

Referenced by FP_TREE_MODEL_ADAPTER::AddLibraries(), AddLibraries(), AddLibrary(), PCB_BASE_FRAME::SelectFootprintFromLibTree(), and FP_TREE_SYNCHRONIZING_ADAPTER::Sync().

◆ DoAddLibraryNode()

LIB_TREE_NODE_LIB & LIB_TREE_MODEL_ADAPTER::DoAddLibraryNode ( wxString const &  aNodeName,
wxString const &  aDesc 
)
protectedinherited

Definition at line 157 of file lib_tree_model_adapter.cpp.

159 {
160  LIB_TREE_NODE_LIB& lib_node = m_tree.AddLib( aNodeName, aDesc );
161 
162  lib_node.m_Pinned = m_pinnedLibs.Index( lib_node.m_LibId.GetLibNickname() ) != wxNOT_FOUND;
163 
164  return lib_node;
165 }
Node type: library.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
LIB_TREE_NODE_LIB & AddLib(wxString const &aName, wxString const &aDesc)
Construct an empty library node, add it to the root, and return it.

References LIB_TREE_NODE_ROOT::AddLib(), LIB_ID::GetLibNickname(), LIB_TREE_NODE::m_LibId, LIB_TREE_NODE::m_Pinned, LIB_TREE_MODEL_ADAPTER::m_pinnedLibs, and LIB_TREE_MODEL_ADAPTER::m_tree.

Referenced by LIB_TREE_MODEL_ADAPTER::DoAddLibrary(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync().

◆ FindItem()

wxDataViewItem LIB_TREE_MODEL_ADAPTER::FindItem ( const LIB_ID aLibId)
inherited

Returns tree item corresponding to part.

Parameters
aLibIdspecifies the part and library name to be searched for.
Returns
Tree data item representing the part. Might be invalid if nothings was found.

Definition at line 340 of file lib_tree_model_adapter.cpp.

341 {
342  for( std::unique_ptr<LIB_TREE_NODE>& lib: m_tree.m_Children )
343  {
344  if( lib->m_Name != aLibId.GetLibNickname() )
345  continue;
346 
347  // if part name is not specified, return the library node
348  if( aLibId.GetLibItemName() == "" )
349  return ToItem( lib.get() );
350 
351  for( std::unique_ptr<LIB_TREE_NODE>& alias: lib->m_Children )
352  {
353  if( alias->m_Name == aLibId.GetLibItemName() )
354  return ToItem( alias.get() );
355  }
356 
357  break; // could not find the part in the requested library
358  }
359 
360  return wxDataViewItem();
361 }
const UTF8 & GetLibItemName() const
Definition: lib_id.h:106
static wxDataViewItem ToItem(LIB_TREE_NODE const *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
PTR_VECTOR m_Children

References LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), LIB_TREE_NODE::m_Children, LIB_TREE_MODEL_ADAPTER::m_tree, and LIB_TREE_MODEL_ADAPTER::ToItem().

◆ FinishTreeInitialization()

void LIB_TREE_MODEL_ADAPTER::FinishTreeInitialization ( )
inherited

A final-stage initialization to be called after the window hierarchy has been realized and the window sizes set.

Definition at line 377 of file lib_tree_model_adapter.cpp.

378 {
379  m_col_part->SetWidth( m_colWidths[PART_COL] );
380  m_col_desc->SetWidth( m_colWidths[DESC_COL] );
381 }

References LIB_TREE_MODEL_ADAPTER::DESC_COL, LIB_TREE_MODEL_ADAPTER::m_col_desc, LIB_TREE_MODEL_ADAPTER::m_col_part, LIB_TREE_MODEL_ADAPTER::m_colWidths, and LIB_TREE_MODEL_ADAPTER::PART_COL.

◆ Freeze()

void LIB_TREE_MODEL_ADAPTER::Freeze ( )
inlineinherited

◆ GenerateInfo()

wxString SYMBOL_TREE_MODEL_ADAPTER::GenerateInfo ( LIB_ID const &  aLibId,
int  aUnit 
)
overridevirtual

Reimplemented from LIB_TREE_MODEL_ADAPTER.

Definition at line 167 of file symbol_tree_model_adapter.cpp.

168 {
169  return GenerateAliasInfo( m_libs, aLibId, aUnit );
170 }
wxString GenerateAliasInfo(SYMBOL_LIB_TABLE *aSymLibTable, LIB_ID const &aLibId, int aUnit)
Return an HTML page describing a LIB_ID in a SYMBOL_LIB_TABLE.

References GenerateAliasInfo(), and m_libs.

◆ GetAliasFor()

LIB_ID LIB_TREE_MODEL_ADAPTER::GetAliasFor ( const wxDataViewItem &  aSelection) const
inherited

Return the alias for the given item.

Parameters
aSelectionitem from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection())
Returns
alias, or nullptr if none is selected

Definition at line 296 of file lib_tree_model_adapter.cpp.

297 {
298  const LIB_TREE_NODE* node = ToNode( aSelection );
299 
300  LIB_ID emptyId;
301 
302  if( !node )
303  return emptyId;
304 
305  return node->m_LibId;
306 }
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.

References LIB_TREE_NODE::m_LibId, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetAttr()

bool LIB_TREE_MODEL_ADAPTER::GetAttr ( wxDataViewItem const &  aItem,
unsigned int  aCol,
wxDataViewItemAttr &  aAttr 
) const
overrideprotectedinherited

Get any formatting for an item.

Parameters
aItemitem to get formatting for
aColcolumn number of interest
aAttrreceiver for attributes
Returns
true if the item has non-default attributes

Definition at line 467 of file lib_tree_model_adapter.cpp.

470 {
471  if( IsFrozen() )
472  return false;
473 
474  LIB_TREE_NODE* node = ToNode( aItem );
475  wxASSERT( node );
476 
477  if( node->m_Type != LIB_TREE_NODE::LIBID )
478  {
479  // Currently only aliases are formatted at all
480  return false;
481  }
482 
483  if( !node->m_IsRoot && aCol == 0 )
484  {
485  // Names of non-root aliases are italicized
486  aAttr.SetItalic( true );
487  return true;
488  }
489  else
490  {
491  return false;
492  }
493 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type

References LIB_TREE_MODEL_ADAPTER::IsFrozen(), LIB_TREE_NODE::LIBID, LIB_TREE_NODE::m_IsRoot, LIB_TREE_NODE::m_Type, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetChildren()

unsigned int LIB_TREE_MODEL_ADAPTER::GetChildren ( wxDataViewItem const &  aItem,
wxDataViewItemArray &  aChildren 
) const
overrideinherited

Populate a list of all the children of an item.

Returns
number of children

Definition at line 364 of file lib_tree_model_adapter.cpp.

366 {
367  const LIB_TREE_NODE* node = ( aItem.IsOk() ? ToNode( aItem ) : &m_tree );
368 
369  if( node->m_Type != LIB_TREE_NODE::TYPE::LIBID
370  || ( m_show_units && node->m_Type == LIB_TREE_NODE::TYPE::LIBID ) )
371  return IntoArray( *node, aChildren );
372  else
373  return 0;
374 }
static unsigned int IntoArray(LIB_TREE_NODE const &aNode, wxDataViewItemArray &aChildren)
Convert SYM_TREE_NODE's children to wxDataViewItemArray.
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type

References LIB_TREE_MODEL_ADAPTER::IntoArray(), LIB_TREE_MODEL_ADAPTER::m_show_units, LIB_TREE_MODEL_ADAPTER::m_tree, LIB_TREE_NODE::m_Type, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetColumnCount()

unsigned int LIB_TREE_MODEL_ADAPTER::GetColumnCount ( ) const
inlineoverrideprotectedinherited

Definition at line 319 of file lib_tree_model_adapter.h.

319 { return NUM_COLS; }

References LIB_TREE_MODEL_ADAPTER::NUM_COLS.

◆ GetColumnType()

wxString LIB_TREE_MODEL_ADAPTER::GetColumnType ( unsigned int  aCol) const
inlineoverrideprotectedinherited

Return the type of data stored in the column as indicated by wxVariant::GetType()

Definition at line 324 of file lib_tree_model_adapter.h.

324 { return "string"; }

◆ GetContextMenuTool()

virtual TOOL_INTERACTIVE* LIB_TREE_MODEL_ADAPTER::GetContextMenuTool ( )
inlinevirtualinherited

Reimplemented in SYMBOL_TREE_SYNCHRONIZING_ADAPTER, and FP_TREE_SYNCHRONIZING_ADAPTER.

Definition at line 274 of file lib_tree_model_adapter.h.

274 { return nullptr; }

◆ GetFilter()

SYM_FILTER_TYPE LIB_TREE_MODEL_ADAPTER::GetFilter ( ) const
inlineinherited

Return the active filter.

Definition at line 142 of file lib_tree_model_adapter.h.

142 { return m_filter; }

References LIB_TREE_MODEL_ADAPTER::m_filter.

Referenced by AddLibraries(), and AddLibrary().

◆ GetItemCount()

int LIB_TREE_MODEL_ADAPTER::GetItemCount ( ) const
inherited

Return the number of symbols loaded in the tree.

Definition at line 329 of file lib_tree_model_adapter.cpp.

330 {
331  int n = 0;
332 
333  for( const std::unique_ptr<LIB_TREE_NODE>& lib: m_tree.m_Children )
334  n += lib->m_Children.size();
335 
336  return n;
337 }
PTR_VECTOR m_Children

References LIB_TREE_NODE::m_Children, and LIB_TREE_MODEL_ADAPTER::m_tree.

Referenced by PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ GetLibrariesCount()

virtual int LIB_TREE_MODEL_ADAPTER::GetLibrariesCount ( ) const
inlinevirtualinherited

Return the number of libraries loaded in the tree.

Reimplemented in SYMBOL_TREE_SYNCHRONIZING_ADAPTER, and FP_TREE_SYNCHRONIZING_ADAPTER.

Definition at line 243 of file lib_tree_model_adapter.h.

244  {
245  return m_tree.m_Children.size();
246  }
PTR_VECTOR m_Children

References LIB_TREE_NODE::m_Children, and LIB_TREE_MODEL_ADAPTER::m_tree.

Referenced by SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetLibrariesCount().

◆ GetParent()

wxDataViewItem LIB_TREE_MODEL_ADAPTER::GetParent ( wxDataViewItem const &  aItem) const
overrideprotectedinherited

Get the parent of an item.

Returns
parent of aItem, or an invalid wxDataViewItem if parent is root

Definition at line 424 of file lib_tree_model_adapter.cpp.

425 {
426  if( m_freeze )
427  return ToItem( nullptr );
428 
429  LIB_TREE_NODE* node = ToNode( aItem );
430  LIB_TREE_NODE* parent = node ? node->m_Parent : nullptr;
431 
432  // wxDataViewModel has no root node, but rather top-level elements have
433  // an invalid (null) parent.
434  if( !node || !parent || parent->m_Type == LIB_TREE_NODE::TYPE::ROOT )
435  return ToItem( nullptr );
436  else
437  return ToItem( parent );
438 }
static wxDataViewItem ToItem(LIB_TREE_NODE const *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
LIB_TREE_NODE * m_Parent
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type

References LIB_TREE_MODEL_ADAPTER::m_freeze, LIB_TREE_NODE::m_Parent, LIB_TREE_NODE::m_Type, LIB_TREE_MODEL_ADAPTER::ToItem(), and LIB_TREE_MODEL_ADAPTER::ToNode().

Referenced by LIB_TREE_MODEL_ADAPTER::UpdateSearchString().

◆ GetPinningSymbol()

const wxString LIB_TREE_MODEL_ADAPTER::GetPinningSymbol ( ) const
inlineprotectedinherited
Returns
a unicode string to mark a node name like a pinned library name This is not an ASCII7 char, but a unicode char

Definition at line 362 of file lib_tree_model_adapter.h.

363  {
364  return wxString::FromUTF8( "☆ " );
365  }

Referenced by FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), and SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue().

◆ GetTreeNodeFor()

LIB_TREE_NODE * LIB_TREE_MODEL_ADAPTER::GetTreeNodeFor ( const wxDataViewItem &  aSelection) const
inherited

Definition at line 323 of file lib_tree_model_adapter.cpp.

324 {
325  return ToNode( aSelection );
326 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.

References LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetTypeFor()

LIB_TREE_NODE::TYPE LIB_TREE_MODEL_ADAPTER::GetTypeFor ( const wxDataViewItem &  aSelection) const
inherited

Return node type for the given item.

Parameters
aSelectionitem from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection())
Returns
Type of the selected node, might be INVALID.

Definition at line 316 of file lib_tree_model_adapter.cpp.

317 {
318  const LIB_TREE_NODE* node = ToNode( aSelection );
319  return node ? node->m_Type : LIB_TREE_NODE::INVALID;
320 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
enum TYPE m_Type

References LIB_TREE_NODE::INVALID, LIB_TREE_NODE::m_Type, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetUnitFor()

int LIB_TREE_MODEL_ADAPTER::GetUnitFor ( const wxDataViewItem &  aSelection) const
inherited

Return the unit for the given item.

Parameters
aSelectionitem from the wxDataViewCtrl (see wxDataViewCtrl::GetSelection())
Returns
Unit, or zero if the alias itself is selected. Return valid is invalid if GetAliasFor() returns nullptr.

Definition at line 309 of file lib_tree_model_adapter.cpp.

310 {
311  const LIB_TREE_NODE* node = ToNode( aSelection );
312  return node ? node->m_Unit : 0;
313 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.

References LIB_TREE_NODE::m_Unit, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ GetValue()

void LIB_TREE_MODEL_ADAPTER::GetValue ( wxVariant &  aVariant,
wxDataViewItem const &  aItem,
unsigned int  aCol 
) const
overrideprotectedinherited

Get the value of an item.

Parameters
aVariantwxVariant to receive the data
aItemitem whose data will be placed into aVariant
aColcolumn number of the data

Definition at line 441 of file lib_tree_model_adapter.cpp.

444 {
445  if( IsFrozen() )
446  {
447  aVariant = wxEmptyString;
448  return;
449  }
450 
451  LIB_TREE_NODE* node = ToNode( aItem );
452  wxASSERT( node );
453 
454  switch( aCol )
455  {
456  default: // column == -1 is used for default Compare function
457  case 0:
458  aVariant = node->m_Name;
459  break;
460  case 1:
461  aVariant = node->m_Desc;
462  break;
463  }
464 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.

References LIB_TREE_MODEL_ADAPTER::IsFrozen(), LIB_TREE_NODE::m_Desc, LIB_TREE_NODE::m_Name, and LIB_TREE_MODEL_ADAPTER::ToNode().

◆ HasContainerColumns()

bool LIB_TREE_MODEL_ADAPTER::HasContainerColumns ( wxDataViewItem const &  aItem) const
overrideprotectedinherited

Check whether a container has columns too.

Definition at line 411 of file lib_tree_model_adapter.cpp.

412 {
413  return IsContainer( aItem );
414 }
bool IsContainer(wxDataViewItem const &aItem) const override
Check whether an item can have children.

References LIB_TREE_MODEL_ADAPTER::IsContainer().

◆ IntoArray()

unsigned int LIB_TREE_MODEL_ADAPTER::IntoArray ( LIB_TREE_NODE const &  aNode,
wxDataViewItemArray &  aChildren 
)
staticprotectedinherited

Convert SYM_TREE_NODE's children to wxDataViewItemArray.

Definition at line 51 of file lib_tree_model_adapter.cpp.

53 {
54  unsigned int n = 0;
55 
56  for( std::unique_ptr<LIB_TREE_NODE> const& child: aNode.m_Children )
57  {
58  if( child->m_Score > 0 )
59  {
60  aChildren.Add( ToItem( &*child ) );
61  ++n;
62  }
63  }
64 
65  return n;
66 }
static wxDataViewItem ToItem(LIB_TREE_NODE const *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.

References LIB_TREE_NODE::m_Children, and LIB_TREE_MODEL_ADAPTER::ToItem().

Referenced by LIB_TREE_MODEL_ADAPTER::GetChildren().

◆ IsContainer()

bool LIB_TREE_MODEL_ADAPTER::IsContainer ( wxDataViewItem const &  aItem) const
overrideprotectedinherited

Check whether an item can have children.

Definition at line 417 of file lib_tree_model_adapter.cpp.

418 {
419  LIB_TREE_NODE* node = ToNode( aItem );
420  return node ? node->m_Children.size() : true;
421 }
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
PTR_VECTOR m_Children

References LIB_TREE_NODE::m_Children, and LIB_TREE_MODEL_ADAPTER::ToNode().

Referenced by LIB_TREE_MODEL_ADAPTER::HasContainerColumns().

◆ IsFrozen()

◆ RefreshTree()

void LIB_TREE_MODEL_ADAPTER::RefreshTree ( )
inherited

Definition at line 384 of file lib_tree_model_adapter.cpp.

385 {
386  // Yes, this is an enormous hack. But it works on all platforms, it doesn't suffer
387  // the On^2 sorting issues that ItemChanged() does on OSX, and it doesn't lose the
388  // user's scroll position (which re-attaching or deleting/re-inserting columns does).
389  static int walk = 1;
390 
391  int partWidth = m_col_part->GetWidth();
392  int descWidth = m_col_desc->GetWidth();
393 
394  // Only use the widths read back if they are non-zero.
395  // GTK returns the displayed width of the column, which is not calculated immediately
396  if( descWidth > 0 )
397  {
398  m_colWidths[PART_COL] = partWidth;
399  m_colWidths[DESC_COL] = descWidth;
400  }
401 
402  m_colWidths[PART_COL] += walk;
403  m_colWidths[DESC_COL] -= walk;
404 
405  m_col_part->SetWidth( m_colWidths[PART_COL] );
406  m_col_desc->SetWidth( m_colWidths[DESC_COL] );
407  walk = -walk;
408 }

References LIB_TREE_MODEL_ADAPTER::DESC_COL, LIB_TREE_MODEL_ADAPTER::m_col_desc, LIB_TREE_MODEL_ADAPTER::m_col_part, LIB_TREE_MODEL_ADAPTER::m_colWidths, and LIB_TREE_MODEL_ADAPTER::PART_COL.

◆ SaveColWidths()

void LIB_TREE_MODEL_ADAPTER::SaveColWidths ( )
inherited

Save the column widths to the config file.

This requires the tree view to still be valid.

Definition at line 104 of file lib_tree_model_adapter.cpp.

105 {
106  if( m_widget )
107  {
109  cfg->m_LibTree.column_width = m_widget->GetColumn( PART_COL )->GetWidth();
110  }
111 }
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:92
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.

References APP_SETTINGS_BASE::LIB_TREE::column_width, Kiface(), KIFACE_I::KifaceSettings(), APP_SETTINGS_BASE::m_LibTree, LIB_TREE_MODEL_ADAPTER::m_widget, and LIB_TREE_MODEL_ADAPTER::PART_COL.

◆ SavePinnedItems()

void LIB_TREE_MODEL_ADAPTER::SavePinnedItems ( )
inherited

Definition at line 114 of file lib_tree_model_adapter.cpp.

115 {
117 
118  std::vector<wxString>& entries = ( m_pinnedKey == "pinned_symbol_libs" ) ?
119  project.m_PinnedSymbolLibs :
120  project.m_PinnedFootprintLibs;
121 
122  entries.clear();
123  m_pinnedLibs.clear();
124 
125  for( std::unique_ptr<LIB_TREE_NODE>& child: m_tree.m_Children )
126  {
127  if( child->m_Pinned )
128  {
129  m_pinnedLibs.push_back( child->m_LibId.GetLibNickname() );
130  entries.push_back( child->m_LibId.GetLibNickname() );
131  }
132  }
133 
134 
135 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:186
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
The backing store for a PROJECT, in JSON format.
Definition: project_file.h:64
PTR_VECTOR m_Children

References PROJECT::GetProjectFile(), KIWAY_HOLDER::Kiway(), LIB_TREE_NODE::m_Children, LIB_TREE_MODEL_ADAPTER::m_parent, LIB_TREE_MODEL_ADAPTER::m_pinnedKey, LIB_TREE_MODEL_ADAPTER::m_pinnedLibs, LIB_TREE_MODEL_ADAPTER::m_tree, KIWAY::Prj(), and project.

◆ SetFilter()

void LIB_TREE_MODEL_ADAPTER::SetFilter ( SYM_FILTER_TYPE  aFilter)
inherited

Set the symbol filter type.

Must be set before adding libraries

Parameters
aFilterif SYM_FILTER_POWER, only power parts are loaded

Definition at line 138 of file lib_tree_model_adapter.cpp.

139 {
140  m_filter = aFilter;
141 }

References LIB_TREE_MODEL_ADAPTER::m_filter.

◆ SetPreselectNode()

void LIB_TREE_MODEL_ADAPTER::SetPreselectNode ( LIB_ID const &  aLibId,
int  aUnit 
)
inherited

Set the symbol name to be selected if there are no search results.

May be set at any time; updates at the next UpdateSearchString().

Parameters
aLibIdsymbol LIB_ID to be selected
aUnitunit to be selected, if > 0 (0 selects the alias itself)

Definition at line 150 of file lib_tree_model_adapter.cpp.

151 {
152  m_preselect_lib_id = aLibId;
153  m_preselect_unit = aUnit;
154 }

References LIB_TREE_MODEL_ADAPTER::m_preselect_lib_id, and LIB_TREE_MODEL_ADAPTER::m_preselect_unit.

Referenced by PCB_BASE_FRAME::SelectFootprintFromLibTree().

◆ SetValue()

bool LIB_TREE_MODEL_ADAPTER::SetValue ( wxVariant const &  aVariant,
wxDataViewItem const &  aItem,
unsigned int  aCol 
)
inlineoverrideprotectedinherited

Set the value of an item.

Does nothing - this model doesn't support editing.

Definition at line 341 of file lib_tree_model_adapter.h.

343  { return false; }

◆ ShowUnits()

void LIB_TREE_MODEL_ADAPTER::ShowUnits ( bool  aShow)
inherited

Whether or not to show units.

May be set at any time; updates at the next UpdateSearchString()

Parameters
aShowif true, units are displayed

Definition at line 144 of file lib_tree_model_adapter.cpp.

145 {
146  m_show_units = aShow;
147 }

References LIB_TREE_MODEL_ADAPTER::m_show_units.

◆ Thaw()

void LIB_TREE_MODEL_ADAPTER::Thaw ( )
inlineinherited

◆ ToItem()

wxDataViewItem LIB_TREE_MODEL_ADAPTER::ToItem ( LIB_TREE_NODE const *  aNode)
staticprotectedinherited

Convert #SYM_TREE_NODE -> wxDataViewItem.

Definition at line 39 of file lib_tree_model_adapter.cpp.

40 {
41  return wxDataViewItem( const_cast<void*>( static_cast<void const*>( aNode ) ) );
42 }

Referenced by LIB_TREE_MODEL_ADAPTER::FindItem(), LIB_TREE_MODEL_ADAPTER::GetParent(), and LIB_TREE_MODEL_ADAPTER::IntoArray().

◆ ToNode()

◆ UpdateSearchString()

void LIB_TREE_MODEL_ADAPTER::UpdateSearchString ( wxString const &  aSearch,
bool  aState 
)
inherited

Set the search string provided by the user.

Parameters
aSearchfull, unprocessed search text
aStateif true, we are keeping the state and so we shouldn't collapse the tree

Definition at line 181 of file lib_tree_model_adapter.cpp.

182 {
183  {
184  wxWindowUpdateLocker updateLock( m_widget );
185 
186  // Even with the updateLock, wxWidgets sometimes ties its knickers in a knot trying to
187  // run a wxdataview_selection_changed_callback() on a row that has been deleted.
188  // https://bugs.launchpad.net/kicad/+bug/1756255
189  m_widget->UnselectAll();
190 
191  // This collapse is required before the call to "Freeze()" below. Once Freeze()
192  // is called, GetParent() will return nullptr. While this works for some calls, it
193  // segfaults when we have any expanded elements b/c the sub units in the tree don't
194  // have explicit references that are maintained over a search
195  // The tree will be expanded again below when we get our matches
196  //
197  // Also note that this cannot happen when we have deleted a symbol as GTK will also
198  // iterate over the tree in this case and find a symbol that has an invalid link
199  // and crash https://gitlab.com/kicad/code/kicad/-/issues/6910
200  if( !aState && !aSearch.IsNull() && m_tree.m_Children.size() )
201  {
202  for( std::unique_ptr<LIB_TREE_NODE>& child: m_tree.m_Children )
203  m_widget->Collapse( wxDataViewItem( &*child ) );
204  }
205 
206  // DO NOT REMOVE THE FREEZE/THAW. This freeze/thaw is a flag for this model adapter
207  // that tells it when it shouldn't trust any of the data in the model. When set, it will
208  // not return invalid data to the UI, since this invalid data can cause crashes.
209  // This is different than the update locker, which locks the UI aspects only.
210  Freeze();
211  BeforeReset();
212 
213  m_tree.ResetScore();
214 
215  for( std::unique_ptr<LIB_TREE_NODE>& child: m_tree.m_Children )
216  {
217  if( child->m_Pinned )
218  child->m_Score *= 2;
219  }
220 
221  wxStringTokenizer tokenizer( aSearch );
222 
223  while( tokenizer.HasMoreTokens() )
224  {
225  const wxString term = tokenizer.GetNextToken().Lower();
226  EDA_COMBINED_MATCHER matcher( term );
227 
228  m_tree.UpdateScore( matcher );
229  }
230 
231  m_tree.SortNodes();
232  AfterReset();
233  Thaw();
234  }
235 
236  LIB_TREE_NODE* bestMatch = ShowResults();
237 
238  if( !bestMatch )
239  bestMatch = ShowPreselect();
240 
241  if( !bestMatch )
242  bestMatch = ShowSingleLibrary();
243 
244  if( bestMatch )
245  {
246  wxDataViewItem item = wxDataViewItem( bestMatch );
247  m_widget->Select( item );
248 
249  // Make sure the *parent* item is visible. The selected item is the
250  // first (shown) child of the parent. So it's always right below the parent,
251  // and this way the user can also see what library the selected part belongs to,
252  // without having a case where the selection is off the screen (unless the
253  // window is a single row high, which is unlikely)
254  //
255  // This also happens to circumvent https://bugs.launchpad.net/kicad/+bug/1804400
256  // which appears to be a GTK+3 bug.
257  {
258  wxDataViewItem parent = GetParent( item );
259 
260  if( parent.IsOk() )
261  item = parent;
262  }
263 
264  m_widget->EnsureVisible( item );
265  }
266 }
void SortNodes()
Sort child nodes quickly and recursively (IntrinsicRanks must have been set).
LIB_TREE_NODE * ShowResults()
Find and expand successful search results.
LIB_TREE_NODE * ShowPreselect()
Find and expand preselected node.
wxDataViewItem GetParent(wxDataViewItem const &aItem) const override
Get the parent of an item.
void ResetScore()
Initialize score to kLowestDefaultScore, recursively.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
virtual void UpdateScore(EDA_COMBINED_MATCHER &aMatcher) override
Update the score for this part.
LIB_TREE_NODE * ShowSingleLibrary()
Find and expand a library if there is only one.
PTR_VECTOR m_Children

References LIB_TREE_MODEL_ADAPTER::Freeze(), LIB_TREE_MODEL_ADAPTER::GetParent(), LIB_TREE_NODE::m_Children, LIB_TREE_MODEL_ADAPTER::m_tree, LIB_TREE_MODEL_ADAPTER::m_widget, LIB_TREE_NODE::ResetScore(), LIB_TREE_MODEL_ADAPTER::ShowPreselect(), LIB_TREE_MODEL_ADAPTER::ShowResults(), LIB_TREE_MODEL_ADAPTER::ShowSingleLibrary(), LIB_TREE_NODE::SortNodes(), LIB_TREE_MODEL_ADAPTER::Thaw(), and LIB_TREE_NODE_ROOT::UpdateScore().

Friends And Related Function Documentation

◆ SYMBOL_ASYNC_LOADER

friend class SYMBOL_ASYNC_LOADER
friend

Definition at line 66 of file symbol_tree_model_adapter.h.

Member Data Documentation

◆ m_libs

SYMBOL_LIB_TABLE* SYMBOL_TREE_MODEL_ADAPTER::m_libs
private

Definition at line 72 of file symbol_tree_model_adapter.h.

Referenced by AddLibraries(), AddLibrary(), and GenerateInfo().

◆ m_show_progress

bool SYMBOL_TREE_MODEL_ADAPTER::m_show_progress = true
staticprivate

Flag to only show the symbol library table load progress dialog the first time.

Definition at line 70 of file symbol_tree_model_adapter.h.

Referenced by AddLibraries().

◆ m_tree


The documentation for this class was generated from the following files: