40#include <wx/settings.h>
43wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
47 return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
68 return node ? node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY :
true;
76 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync enter" ) );
86 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync freeing/updating nodes" ) );
89 for(
auto it =
m_tree.m_Children.begin(); it !=
m_tree.m_Children.end(); )
91 const wxString&
name = it->get()->m_Name;
96 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow(
name );
97 std::optional<LIB_STATUS> libStatus =
m_libs->GetLibraryStatus(
name );
99 bool loadFailed = libStatus.has_value()
102 if( !optRow.has_value()
103 || ( *optRow )->Disabled()
104 || ( *optRow )->Hidden()
128 for(
const auto& [libName, status] :
m_libs->GetLibraryStatuses() )
133 if(
m_libMap.count( libName ) != 0 )
136 std::optional<LIBRARY_TABLE_ROW*> optRow =
m_libs->GetRow( libName );
138 if( !optRow.has_value() || ( *optRow )->Disabled() || ( *optRow )->Hidden() )
144 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( libName,
true );
145 std::vector<LIB_TREE_ITEM*> treeItems;
146 treeItems.reserve( footprints.size() );
149 treeItems.push_back( fp );
151 DoAddLibrary( libName, ( *optRow )->Description(), treeItems, pinned,
true );
158 wxLogTrace( wxT(
"KICAD_TABS_DBG" ), wxT(
"FpSyncAdapter::Sync exit" ) );
164 return m_libs->GetLibraryNames().size();
174 std::vector<FOOTPRINT*> footprints =
m_libs->GetFootprints( aLibNode.
m_Name,
true );
177 std::map<wxString, FOOTPRINT*> fpMap;
180 fpMap[fp->GetFPID().GetLibItemName()] = fp;
185 auto fpIt = fpMap.find( (*nodeIt)->m_Name );
187 if( fpIt != fpMap.end() )
200 for(
auto& [
name, fp] : fpMap )
208LIB_TREE_NODE::PTR_VECTOR::iterator
213 auto it =
m_tree.m_Children.erase( aLibNodeIt );
225 unsigned int aCol )
const
229 aVariant = wxEmptyString;
243 m_frame->GetBoard()->GetFirstFootprint()->GetFPID().GetUniStringLibItemName();
246 if(
m_frame->GetScreen()->IsContentModified() )
247 aVariant = node->
m_Name + wxT(
" *" );
267 node->
m_Desc =
m_frame->GetBoard()->GetFirstFootprint()->GetLibDescription();
269 else if( node->
m_Type == LIB_TREE_NODE::TYPE::LIBRARY )
279 descStr.Replace( wxS(
"\n" ), wxS(
" " ) );
293 wxDataViewItemAttr& aAttr )
const
303 if(
m_frame->IsCurrentFPFromBoard() )
307 wxCHECK( node,
false );
311 case LIB_TREE_NODE::TYPE::LIBRARY:
312 if( node->
m_Name ==
m_frame->GetLoadedFPID().GetLibNickname().wx_str() )
317 aAttr.SetStrikethrough(
true );
322 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
323 aAttr.SetBold(
true );
327 case LIB_TREE_NODE::TYPE::ITEM:
331 aAttr.SetStrikethrough(
true );
335 if(
m_frame->GetScreen()->IsContentModified() && !
m_frame->IsCurrentFPFromBoard() )
336 aAttr.SetBold(
true );
351 wxCHECK( node,
false );
365 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
370 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
371 aParent->SetSizer( mainSizer );
378 mainSizer->Add( preview, 1, wxEXPAND | wxALL, 1 );
388 wxWindow* previewWindow = wxWindow::FindWindowByName(
c_previewName, aParent );
392 preview->GetCanvas()->SetEvtHandlerEnabled(
false );
393 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