From db4bd0c2db504323580e680973a50085c04fa989 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 17 Nov 2017 11:44:16 +0100 Subject: [PATCH] Library Editor: fixed dynamic updates Duplicate entries were caused by multiple model assignment done by CMP_TREE_MODEL_ADAPTER_BASE::AttachTo(). --- eeschema/cmp_tree_model_adapter_base.cpp | 4 ++-- eeschema/lib_manager_adapter.cpp | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/eeschema/cmp_tree_model_adapter_base.cpp b/eeschema/cmp_tree_model_adapter_base.cpp index 9c3515bb17..519a91b6e8 100644 --- a/eeschema/cmp_tree_model_adapter_base.cpp +++ b/eeschema/cmp_tree_model_adapter_base.cpp @@ -158,7 +158,6 @@ void CMP_TREE_MODEL_ADAPTER_BASE::UpdateSearchString( wxString const& aSearch ) m_tree.SortNodes(); Cleared(); - AttachTo( m_widget ); ShowResults() || ShowPreselect() || ShowSingleLibrary(); } @@ -289,7 +288,8 @@ unsigned int CMP_TREE_MODEL_ADAPTER_BASE::GetChildren( { auto node = ( aItem.IsOk() ? ToNode( aItem ) : &m_tree ); - if( node->Type != CMP_TREE_NODE::TYPE::LIBID || m_show_units ) + if( node->Type != CMP_TREE_NODE::TYPE::LIBID + || ( m_show_units && node->Type == CMP_TREE_NODE::TYPE::UNIT ) ) return IntoArray( *node, aChildren ); else return 0; diff --git a/eeschema/lib_manager_adapter.cpp b/eeschema/lib_manager_adapter.cpp index eb09efbc20..1a58d32335 100644 --- a/eeschema/lib_manager_adapter.cpp +++ b/eeschema/lib_manager_adapter.cpp @@ -76,7 +76,7 @@ void LIB_MANAGER_ADAPTER::AddAliasList( const wxString& aNodeName, bool LIB_MANAGER_ADAPTER::IsContainer( const wxDataViewItem& aItem ) const { const CMP_TREE_NODE* node = ToNode( aItem ); - return node && node->Type == CMP_TREE_NODE::LIB; + return node ? node->Type == CMP_TREE_NODE::LIB : true; } @@ -194,12 +194,7 @@ void LIB_MANAGER_ADAPTER::addAliases( CMP_TREE_NODE_LIB& aLibNode ) void LIB_MANAGER_ADAPTER::finishUpdate() { m_tree.AssignIntrinsicRanks(); -#ifdef __WINDOWS__ - // Normally one would call Item{Added,Changed,Deleted}() to notify the view - // about changes, but ItemAdded() causes duplicate entries on Windows. - // The only sensible way is to call Cleared() that rebuilds the model. - Cleared(); -#endif /* __WINDOWS__ */ + m_tree.SortNodes(); Resort(); }