Allow EDA_COMBINED_MATCHER use in KiCad find architecture.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/12532
This commit is contained in:
Jeff Young 2023-06-10 14:49:37 +01:00
parent d18b0c62f6
commit f66b9f75a3
6 changed files with 42 additions and 13 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -32,6 +32,7 @@
#include <wx/log.h>
#include <wx/fdrepdlg.h>
#include <eda_pattern_match.h>
EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) :
m_parent( parent ),
@ -128,7 +129,13 @@ bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchDat
searchText.MakeUpper();
}
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::PERMISSIVE )
{
EDA_COMBINED_MATCHER matcher( searchText, CTX_SEARCH );
return matcher.Find( text );
}
else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
{
int ii = 0;

View File

@ -395,6 +395,12 @@ EDA_COMBINED_MATCHER::EDA_COMBINED_MATCHER( const wxString& aPattern,
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
break;
case CTX_SEARCH:
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_REGEX>() );
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
break;
}
}

View File

@ -124,7 +124,9 @@ int SYMBOL_SEARCH_HANDLER::Search( const wxString& aQuery )
SCH_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
frp.searchCurrentSheetOnly = false;
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
@ -202,7 +204,9 @@ int TEXT_SEARCH_HANDLER::Search( const wxString& aQuery )
SCH_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
frp.searchCurrentSheetOnly = false;
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
@ -302,7 +306,9 @@ int LABEL_SEARCH_HANDLER::Search( const wxString& aQuery )
SCH_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
frp.searchCurrentSheetOnly = false;
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )

View File

@ -198,7 +198,8 @@ enum COMBINED_MATCHER_CONTEXT
{
CTX_LIBITEM,
CTX_NETCLASS,
CTX_SIGNAL
CTX_SIGNAL,
CTX_SEARCH
};

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2022 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -30,7 +30,8 @@ enum class EDA_SEARCH_MATCH_MODE
{
PLAIN,
WHOLEWORD,
WILDCARD
WILDCARD,
PERMISSIVE
};
struct EDA_SEARCH_DATA

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -63,7 +63,9 @@ int FOOTPRINT_SEARCH_HANDLER::Search( const wxString& aQuery )
EDA_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
for( FOOTPRINT* fp : board->Footprints() )
{
@ -139,7 +141,9 @@ int ZONE_SEARCH_HANDLER::Search( const wxString& aQuery )
EDA_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
for( BOARD_ITEM* item : board->Zones() )
{
@ -222,7 +226,9 @@ int TEXT_SEARCH_HANDLER::Search( const wxString& aQuery )
EDA_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
for( BOARD_ITEM* item : board->Drawings() )
{
@ -304,7 +310,9 @@ int NETS_SEARCH_HANDLER::Search( const wxString& aQuery )
EDA_SEARCH_DATA frp;
frp.findString = aQuery;
frp.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
// Try to handle whatever the user throws at us (substring, wildcards, regex, etc.)
frp.matchMode = EDA_SEARCH_MATCH_MODE::PERMISSIVE;
BOARD* board = m_frame->GetBoard();