44#include <wx/settings.h>
47wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
51 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
72 return node ? node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY :
true;
80 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync enter" ) );
90 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync freeing/updating nodes" ) );
93 for(
auto it =
m_tree.m_Children.begin(); it !=
m_tree.m_Children.end(); )
95 const wxString&
name = it->get()->m_Name;
100 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow(
name );
101 std::optional<LIB_STATUS> libStatus =
m_libs->GetLibraryStatus(
name );
103 bool loadFailed = libStatus.has_value()
106 if( !optRow.has_value()
107 || ( *optRow )->Disabled()
108 || ( *optRow )->Hidden()
132 for(
const auto& [libName, status] :
m_libs->GetLibraryStatuses() )
137 if(
m_libMap.count( libName ) != 0 )
140 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow( libName );
142 if( !optRow.has_value() || ( *optRow )->Disabled() || ( *optRow )->Hidden() )
148 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( libName,
true );
149 std::vector<LIB_TREE_ITEM*> treeItems;
150 treeItems.reserve( footprints.size() );
153 treeItems.push_back( fp );
155 DoAddLibrary( libName, ( *optRow )->Description(), treeItems, pinned,
true );
162 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync exit" ) );
168 return m_libs->GetLibraryNames().size();
178 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( aLibNode.
m_Name,
true );
181 std::map<wxString, FOOTPRINT*> fpMap;
184 fpMap[fp->GetFPID().GetLibItemName()] = fp;
189 auto fpIt = fpMap.find( (*nodeIt)->m_Name );
191 if( fpIt != fpMap.end() )
204 for(
auto& [
name, fp] : fpMap )
212LIB_TREE_NODE::PTR_VECTOR::iterator
217 auto it =
m_tree.m_Children.erase( aLibNodeIt );
229 unsigned int aCol )
const
233 aVariant = wxEmptyString;
247 m_frame->GetBoard()->GetFirstFootprint()->GetFPID().GetUniStringLibItemName();
250 if(
m_frame->GetScreen()->IsContentModified() )
251 aVariant = node->
m_Name + wxT(
" *" );
271 node->
m_Desc =
m_frame->GetBoard()->GetFirstFootprint()->GetLibDescription();
273 else if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
283 descStr.Replace( wxS(
"\n" ), wxS(
" " ) );
297 wxDataViewItemAttr& aAttr )
const
307 if(
m_frame->IsCurrentFPFromBoard() )
311 wxCHECK( node,
false );
315 case LIB_TREE_NODE::TYPE::LIBRARY:
316 if( node->
m_Name ==
m_frame->GetLoadedFPID().GetLibNickname().wx_str() )
321 aAttr.SetStrikethrough(
true );
326 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
327 aAttr.SetBold(
true );
331 case LIB_TREE_NODE::TYPE::ITEM:
335 aAttr.SetStrikethrough(
true );
339 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
340 aAttr.SetBold(
true );
355 wxCHECK( node,
false );
369 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
374 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
375 aParent->SetSizer( mainSizer );
382 mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
392 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
396 preview->GetCanvas()->SetEvtHandlerEnabled(
false );
397 preview->GetCanvas()->StopDrawing();
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
FOOTPRINT_LIBRARY_ADAPTER * m_libs
FP_TREE_MODEL_ADAPTER(PCB_BASE_FRAME *aParent, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
Constructor; takes a set of libraries to be included in the search.
FP_TREE_SYNCHRONIZING_ADAPTER(FOOTPRINT_EDIT_FRAME *aFrame, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
bool HasPreview(const wxDataViewItem &aItem) override
void Sync(FOOTPRINT_LIBRARY_ADAPTER *aLibs)
bool GetAttr(wxDataViewItem const &aItem, unsigned int aCol, wxDataViewItemAttr &aAttr) const override
FOOTPRINT_EDIT_FRAME * m_frame
void updateLibrary(LIB_TREE_NODE_LIBRARY &aLibNode)
static wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > Create(FOOTPRINT_EDIT_FRAME *aFrame, FOOTPRINT_LIBRARY_ADAPTER *aLibs)
wxDataViewItem GetCurrentDataViewItem() override
int GetLibrariesCount() const override
Return the number of libraries loaded in the tree.
void ShutdownPreview(wxWindow *aParent) override
bool IsContainer(const wxDataViewItem &aItem) const override
LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary(LIB_TREE_NODE::PTR_VECTOR::iterator &aLibNodeIt)
std::set< wxString > m_libMap
TOOL_INTERACTIVE * GetContextMenuTool() override
void ShowPreview(wxWindow *aParent, const wxDataViewItem &aItem) override
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
RAII guard that detaches the GtkTreeView from the model across a tree rebuild so a deferred frame-clo...
LIB_TREE_NODE_ROOT m_tree
static LIB_TREE_NODE * ToNode(wxDataViewItem aItem)
Convert wxDataViewItem -> #SYM_TREE_NODE.
static wxDataViewItem ToItem(const LIB_TREE_NODE *aNode)
Convert #SYM_TREE_NODE -> wxDataViewItem.
static const wxString GetPinningSymbol()
@ NAME_COL
Library or library item name column.
@ DESC_COL
Library or library description column.
wxDataViewCtrl * m_widget
std::vector< wxString > m_shownColumns
LIB_TREE_NODE_LIBRARY & 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.
wxDataViewItem FindItem(const LIB_ID &aLibId)
Returns tree item corresponding to part.
void Update(LIB_TREE_ITEM *aItem)
Update the node using data from a LIB_ALIAS object.
LIB_TREE_NODE_ITEM & AddItem(LIB_TREE_ITEM *aItem)
Construct a new alias node, add it to this library, and return it.
Model class in the component selector Model-View-Adapter (mediated MVC) architecture.
void AssignIntrinsicRanks(const std::vector< wxString > &aShownColumns, bool presorted=false)
Store intrinsic ranks on all children of this node.
virtual COMMON_SETTINGS * GetCommonSettings() const
The backing store for a PROJECT, in JSON format.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
PGM_BASE & Pgm()
The global program "get" accessor.
wxString UnescapeString(const wxString &aSource)
std::vector< wxString > pinned_fp_libs
static const wxString c_previewName