Reimplement pinning now that we're no longer sorting on score.
This commit is contained in:
parent
00fc225306
commit
120c5b9ac1
|
@ -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 )
|
if( aNode1.m_Type != aNode2.m_Type )
|
||||||
return 0;
|
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 )
|
if( aNode1.m_Parent != aNode2.m_Parent )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -214,12 +214,6 @@ void LIB_TREE_MODEL_ADAPTER::UpdateSearchString( const wxString& aSearch, bool a
|
||||||
|
|
||||||
m_tree.ResetScore();
|
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 );
|
wxStringTokenizer tokenizer( aSearch );
|
||||||
|
|
||||||
while( tokenizer.HasMoreTokens() )
|
while( tokenizer.HasMoreTokens() )
|
||||||
|
|
Loading…
Reference in New Issue