Filter must return true for libraries.
Also fixes a bug where a single symbol library wasn't expanded due to the presence of the "-- already placed --" and "-- recently used --" pseudo-libraries. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16074
This commit is contained in:
parent
229bcc7308
commit
752d2d5295
|
@ -669,11 +669,21 @@ const LIB_TREE_NODE* LIB_TREE_MODEL_ADAPTER::ShowResults()
|
||||||
// If still no matches expand a single library if there is only one
|
// If still no matches expand a single library if there is only one
|
||||||
if( !firstMatch )
|
if( !firstMatch )
|
||||||
{
|
{
|
||||||
|
int libraries = 0;
|
||||||
|
|
||||||
|
for( const std::unique_ptr<LIB_TREE_NODE>& child : m_tree.m_Children )
|
||||||
|
{
|
||||||
|
if( !child->m_Name.StartsWith( "-- " ) )
|
||||||
|
libraries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( libraries != 1 )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
recursiveDescent( m_tree,
|
recursiveDescent( m_tree,
|
||||||
[&]( const LIB_TREE_NODE* n )
|
[&]( const LIB_TREE_NODE* n )
|
||||||
{
|
{
|
||||||
if( n->m_Type == LIB_TREE_NODE::TYPE::LIB_ITEM
|
if( n->m_Type == LIB_TREE_NODE::TYPE::LIB_ITEM )
|
||||||
&& n->m_Parent->m_Parent->m_Children.size() == 1 )
|
|
||||||
{
|
{
|
||||||
firstMatch = n;
|
firstMatch = n;
|
||||||
m_widget->ExpandAncestors( ToItem( n ) );
|
m_widget->ExpandAncestors( ToItem( n ) );
|
||||||
|
|
|
@ -103,13 +103,12 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
||||||
|
|
||||||
if( aFilter->GetFilterPowerSymbols() )
|
if( aFilter->GetFilterPowerSymbols() )
|
||||||
{
|
{
|
||||||
// HACK ALERT: the only filter ever used for symbols is the power filter, so we
|
// HACK ALERT: when loading symbols we presume that *any* filter is a power symbol
|
||||||
// just look for the function pointer being non-null. (What the function does is
|
// filter. So the filter only needs to return true for libraries.
|
||||||
// therefore immaterial as it's never called.)
|
|
||||||
static std::function<bool( LIB_TREE_NODE& )> powerFilter =
|
static std::function<bool( LIB_TREE_NODE& )> powerFilter =
|
||||||
[]( LIB_TREE_NODE& ) -> bool
|
[]( LIB_TREE_NODE& aNode ) -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
adapter->SetFilter( &powerFilter );
|
adapter->SetFilter( &powerFilter );
|
||||||
|
|
Loading…
Reference in New Issue