Reimplement pinning now that we're no longer sorting on score.

This commit is contained in:
Jeff Young 2022-07-09 12:19:58 -06:00
parent 00fc225306
commit 120c5b9ac1
2 changed files with 12 additions and 6 deletions

View File

@ -105,6 +105,18 @@ int LIB_TREE_NODE::Compare( LIB_TREE_NODE const& aNode1, LIB_TREE_NODE const& aN
if( aNode1.m_Type != aNode2.m_Type )
return 0;
// Recently used sorts at top
if( aNode1.m_Name.StartsWith( wxT( "-- " ) ) )
return 1;
else if( aNode2.m_Name.StartsWith( wxT( "-- " ) ) )
return 0;
// Pinned nodes go next
if( aNode1.m_Pinned && !aNode2.m_Pinned )
return 1;
else if( aNode2.m_Pinned && !aNode1.m_Pinned )
return -1;
if( aNode1.m_Parent != aNode2.m_Parent )
return 0;

View File

@ -214,12 +214,6 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( const wxString& aSearch, bool a
m_tree.ResetScore();
for( std::unique_ptr<LIB_TREE_NODE>& child: m_tree.m_Children )
{
if( child->m_Pinned )
child->m_Score *= 2;
}
wxStringTokenizer tokenizer( aSearch );
while( tokenizer.HasMoreTokens() )