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( !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,
|
||||
[&]( const LIB_TREE_NODE* n )
|
||||
{
|
||||
if( n->m_Type == LIB_TREE_NODE::TYPE::LIB_ITEM
|
||||
&& n->m_Parent->m_Parent->m_Children.size() == 1 )
|
||||
if( n->m_Type == LIB_TREE_NODE::TYPE::LIB_ITEM )
|
||||
{
|
||||
firstMatch = n;
|
||||
m_widget->ExpandAncestors( ToItem( n ) );
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
* see SCH_BASE_FRAME::SelectSymbolFromLibrary() for details.
|
||||
* if aFilter == NULL, remove all filtering.
|
||||
*/
|
||||
void SetFilter( std::function<bool( LIB_TREE_NODE& aNode )>* aFilter );
|
||||
void SetFilter( std::function<bool( LIB_TREE_NODE& aNode )>* aFilter );
|
||||
|
||||
private:
|
||||
void OnPaint( wxPaintEvent& aEvent );
|
||||
|
|
|
@ -103,13 +103,12 @@ PANEL_SYMBOL_CHOOSER::PANEL_SYMBOL_CHOOSER( SCH_BASE_FRAME* aFrame, wxWindow* aP
|
|||
|
||||
if( aFilter->GetFilterPowerSymbols() )
|
||||
{
|
||||
// HACK ALERT: the only filter ever used for symbols is the power filter, so we
|
||||
// just look for the function pointer being non-null. (What the function does is
|
||||
// therefore immaterial as it's never called.)
|
||||
// HACK ALERT: when loading symbols we presume that *any* filter is a power symbol
|
||||
// filter. So the filter only needs to return true for libraries.
|
||||
static std::function<bool( LIB_TREE_NODE& )> powerFilter =
|
||||
[]( LIB_TREE_NODE& ) -> bool
|
||||
[]( LIB_TREE_NODE& aNode ) -> bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
adapter->SetFilter( &powerFilter );
|
||||
|
|
Loading…
Reference in New Issue