Browse Source

Update library trees when their items change.

Fixes https://gitlab.com/kicad/code/kicad/issues/4019
pull/16/head
Jeff Young 6 years ago
parent
commit
d875d5850e
  1. 15
      common/lib_tree_model_adapter.cpp
  2. 2
      common/lib_tree_model_adapter.h
  3. 9
      common/widgets/lib_tree.cpp

15
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 );

2
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; }

9
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();
}

Loading…
Cancel
Save