Allow EDA_COMBINED_MATCHER use in KiCad find architecture.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12532
This commit is contained in:
parent
d18b0c62f6
commit
f66b9f75a3
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* 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) 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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
||||||
#include <wx/fdrepdlg.h>
|
#include <wx/fdrepdlg.h>
|
||||||
|
#include <eda_pattern_match.h>
|
||||||
|
|
||||||
EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) :
|
EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) :
|
||||||
m_parent( parent ),
|
m_parent( parent ),
|
||||||
|
@ -128,7 +129,13 @@ bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchDat
|
||||||
searchText.MakeUpper();
|
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;
|
int ii = 0;
|
||||||
|
|
||||||
|
|
|
@ -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_WILDCARD>() );
|
||||||
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
|
AddMatcher( aPattern, std::make_unique<EDA_PATTERN_MATCH_SUBSTR>() );
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,9 @@ int SYMBOL_SEARCH_HANDLER::Search( const wxString& aQuery )
|
||||||
|
|
||||||
SCH_SEARCH_DATA frp;
|
SCH_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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;
|
frp.searchCurrentSheetOnly = false;
|
||||||
|
|
||||||
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
|
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;
|
SCH_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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;
|
frp.searchCurrentSheetOnly = false;
|
||||||
|
|
||||||
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
|
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;
|
SCH_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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;
|
frp.searchCurrentSheetOnly = false;
|
||||||
|
|
||||||
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
|
auto search = [frp]( SCH_ITEM* item, SCH_SHEET_PATH* sheet )
|
||||||
|
|
|
@ -198,7 +198,8 @@ enum COMBINED_MATCHER_CONTEXT
|
||||||
{
|
{
|
||||||
CTX_LIBITEM,
|
CTX_LIBITEM,
|
||||||
CTX_NETCLASS,
|
CTX_NETCLASS,
|
||||||
CTX_SIGNAL
|
CTX_SIGNAL,
|
||||||
|
CTX_SEARCH
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* 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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -30,7 +30,8 @@ enum class EDA_SEARCH_MATCH_MODE
|
||||||
{
|
{
|
||||||
PLAIN,
|
PLAIN,
|
||||||
WHOLEWORD,
|
WHOLEWORD,
|
||||||
WILDCARD
|
WILDCARD,
|
||||||
|
PERMISSIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EDA_SEARCH_DATA
|
struct EDA_SEARCH_DATA
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* 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
|
* 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
|
* 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;
|
EDA_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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() )
|
for( FOOTPRINT* fp : board->Footprints() )
|
||||||
{
|
{
|
||||||
|
@ -139,7 +141,9 @@ int ZONE_SEARCH_HANDLER::Search( const wxString& aQuery )
|
||||||
|
|
||||||
EDA_SEARCH_DATA frp;
|
EDA_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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() )
|
for( BOARD_ITEM* item : board->Zones() )
|
||||||
{
|
{
|
||||||
|
@ -222,7 +226,9 @@ int TEXT_SEARCH_HANDLER::Search( const wxString& aQuery )
|
||||||
|
|
||||||
EDA_SEARCH_DATA frp;
|
EDA_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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() )
|
for( BOARD_ITEM* item : board->Drawings() )
|
||||||
{
|
{
|
||||||
|
@ -304,7 +310,9 @@ int NETS_SEARCH_HANDLER::Search( const wxString& aQuery )
|
||||||
|
|
||||||
EDA_SEARCH_DATA frp;
|
EDA_SEARCH_DATA frp;
|
||||||
frp.findString = aQuery;
|
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();
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue