Fix preselect in CMP_TREE_MODEL_ADAPTER

This commit is contained in:
Chris Pavlina 2017-03-21 22:35:35 -04:00
parent 12b65cf56b
commit b2f1d22bbf
2 changed files with 7 additions and 10 deletions

View File

@ -386,7 +386,12 @@ bool CMP_TREE_MODEL_ADAPTER::ShowPreselect()
return FindAndExpand( m_tree,
[&]( CMP_TREE_NODE const* n )
{
return m_preselect_name == n->Name && m_preselect_unit == n->Unit;
if( n->Type == CMP_TREE_NODE::ALIAS && ( n->Children.empty() || !m_preselect_unit ) )
return m_preselect_name == n->Name;
else if( n->Type == CMP_TREE_NODE::UNIT && m_preselect_unit )
return m_preselect_name == n->Parent->Name && m_preselect_unit == n->Unit;
else
return false;
} );
}

View File

@ -141,15 +141,7 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const SCHLIB_FILTER* aFilte
if( !aHistoryList.empty() )
{
// This is good for a transition for experienced users: giving them a History. Ideally,
// we actually make this part even faster to access with a popup on ALT-a or something.
// the history is under a node named "-- History --"
// However, because it is translatable, and we need to have a node name starting by "-- "
// because we (later) sort all node names alphabetically and this node should be the first,
// we build it with only with "History" string translatable
wxString nodename;
nodename << wxT("-- ") << _("History") << wxT(" --");
adapter->AddAliasList( nodename, aHistoryList, NULL );
adapter->AddAliasList( "-- " + _( "History" ) + " --", aHistoryList, NULL );
adapter->SetPreselectNode( aHistoryList[0], aHistoryLastUnit );
}