diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 50e1aef473..a5b7253954 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -386,6 +386,21 @@ unsigned int LIB_TREE_MODEL_ADAPTER::GetChildren( wxDataViewItem const& aItem, } +void LIB_TREE_MODEL_ADAPTER::RefreshTree( LIB_TREE_NODE* aNode ) +{ + if( !aNode ) + aNode = &m_tree; + + for( auto const& child: aNode->m_Children ) + { + if( child->m_Score > 0 ) + RefreshTree( child.get() ); + } + + ItemChanged( ToItem( aNode ) ); +} + + bool LIB_TREE_MODEL_ADAPTER::HasContainerColumns( wxDataViewItem const& aItem ) const { return IsContainer( aItem ); diff --git a/common/lib_tree_model_adapter.h b/common/lib_tree_model_adapter.h index f06ad68189..a1e2c9c8da 100644 --- a/common/lib_tree_model_adapter.h +++ b/common/lib_tree_model_adapter.h @@ -268,6 +268,8 @@ public: void Thaw() { m_freeze--; } bool IsFrozen() const { return m_freeze; } + void RefreshTree( LIB_TREE_NODE* aNode = nullptr ); + // Allows subclasses to nominate a context menu handler. virtual TOOL_INTERACTIVE* GetContextMenuTool() { return nullptr; } diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index a0d2e6bc76..1d4c7b67d3 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -216,14 +216,7 @@ void LIB_TREE::Regenerate( bool aKeepState ) void LIB_TREE::RefreshLibTree() { -#ifdef __WXOSX__ - // Yes, this is an enormous hack. It should be replaced if anyone can figure out a better - // way to get the OSX version to re-fetch the text and attributes from the dataModel for - // each visible item. - int width = m_tree_ctrl->GetColumn( 0 )->GetWidth(); - m_tree_ctrl->GetColumn( 0 )->SetWidth( width + 1 ); - m_tree_ctrl->GetColumn( 0 )->SetWidth( width ); -#endif + m_adapter->RefreshTree(); }