2012-05-28 23:01:51 +03:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2012-05-29 23:43:17 +03:00
|
|
|
* Copyright (C) 2012 Marco Mattila <marcom99@gmail.com>
|
2018-01-17 15:36:04 +01:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2012-05-28 23:01:51 +03:00
|
|
|
*
|
|
|
|
* 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 Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2023-06-01 09:17:20 +02:00
|
|
|
#include <pcb_edit_frame.h> // Keep this include at top to avoid compil issue on MSYS2
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2020-10-05 00:34:59 +01:00
|
|
|
#include <pcb_text.h>
|
2021-06-03 19:05:43 +01:00
|
|
|
#include <zone.h>
|
2019-11-26 20:46:07 +01:00
|
|
|
#include <dialog_find.h>
|
2021-07-29 10:56:22 +01:00
|
|
|
#include <string_utils.h>
|
2025-01-23 13:12:26 +00:00
|
|
|
#include <hotkeys_basic.h>
|
2019-11-26 20:46:07 +01:00
|
|
|
#include <string>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2019-07-26 17:52:17 -06:00
|
|
|
#include <wx/fdrepdlg.h>
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2025-01-23 13:12:26 +00:00
|
|
|
DIALOG_FIND::DIALOG_FIND( PCB_EDIT_FRAME *aFrame ) :
|
|
|
|
DIALOG_FIND_BASE( aFrame, wxID_ANY, _( "Find" ) ),
|
|
|
|
m_frame( aFrame )
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
m_searchCombo->Append( m_frame->GetFindHistoryList() );
|
2019-07-26 17:52:17 -06:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
while( m_searchCombo->GetCount() > 10 )
|
2019-07-26 17:52:17 -06:00
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
m_frame->GetFindHistoryList().pop_back();
|
|
|
|
m_searchCombo->Delete( 9 );
|
2019-07-26 17:52:17 -06:00
|
|
|
}
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
if( m_searchCombo->GetCount() )
|
|
|
|
{
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
|
|
|
m_searchCombo->SelectAll();
|
|
|
|
}
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2019-11-30 01:00:16 +00:00
|
|
|
m_status->SetLabel( wxEmptyString);
|
2019-12-10 05:49:28 -08:00
|
|
|
m_upToDate = false;
|
|
|
|
|
|
|
|
m_hitList.clear();
|
|
|
|
m_it = m_hitList.begin();
|
2019-11-30 01:00:16 +00:00
|
|
|
|
2025-08-06 16:36:35 -07:00
|
|
|
m_board = m_frame->GetBoard();
|
|
|
|
|
|
|
|
if( m_board )
|
|
|
|
m_board->AddListener( this );
|
|
|
|
|
|
|
|
m_frame->Bind( EDA_EVT_BOARD_CHANGED, &DIALOG_FIND::OnBoardChanged, this );
|
|
|
|
|
2025-01-23 13:12:26 +00:00
|
|
|
if( int hotkey = ACTIONS::showSearch.GetHotKey() )
|
|
|
|
{
|
|
|
|
wxString hotkeyHint = wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( hotkey ) );
|
|
|
|
m_searchPanelLink->SetLabel( m_searchPanelLink->GetLabel() + hotkeyHint );
|
|
|
|
}
|
|
|
|
|
2019-11-30 01:00:16 +00:00
|
|
|
m_findNext->SetDefault();
|
2019-11-26 20:46:07 +01:00
|
|
|
SetInitialFocus( m_searchCombo );
|
2018-09-19 12:30:04 -04:00
|
|
|
|
2019-07-26 17:52:17 -06:00
|
|
|
Center();
|
2017-01-22 21:51:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2025-08-06 16:36:35 -07:00
|
|
|
DIALOG_FIND::~DIALOG_FIND()
|
|
|
|
{
|
|
|
|
if( m_board )
|
|
|
|
m_board->RemoveListener( this );
|
|
|
|
|
|
|
|
m_frame->Unbind( EDA_EVT_BOARD_CHANGED, &DIALOG_FIND::OnBoardChanged, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-19 00:17:07 +00:00
|
|
|
void DIALOG_FIND::Preload( const wxString& aFindString )
|
|
|
|
{
|
|
|
|
if( !aFindString.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_searchCombo->SetValue( aFindString );
|
|
|
|
m_searchCombo->SelectAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
void DIALOG_FIND::onTextEnter( wxCommandEvent& aEvent )
|
2014-10-13 15:23:30 +02:00
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
search( true );
|
2014-10-13 15:23:30 +02:00
|
|
|
}
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
search( true );
|
|
|
|
}
|
2018-09-19 12:30:04 -04:00
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent )
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
search( false );
|
2012-05-28 23:01:51 +03:00
|
|
|
}
|
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
2019-12-10 05:49:28 -08:00
|
|
|
m_upToDate = false;
|
2019-11-26 20:46:07 +01:00
|
|
|
search( true );
|
|
|
|
}
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2025-01-23 13:12:26 +00:00
|
|
|
void DIALOG_FIND::onShowSearchPanel( wxHyperlinkEvent& event )
|
|
|
|
{
|
|
|
|
if( m_frame->IsSearchPaneShown() )
|
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
|
|
|
|
CallAfter(
|
|
|
|
[]()
|
|
|
|
{
|
|
|
|
if( wxWindow* frame = wxWindow::FindWindowByName( PCB_EDIT_FRAME_NAME ) )
|
|
|
|
static_cast<PCB_EDIT_FRAME*>( frame )->FocusSearch();
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->GetToolManager()->RunAction( ACTIONS::showSearch );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
void DIALOG_FIND::search( bool aDirection )
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
2019-07-26 17:52:17 -06:00
|
|
|
PCB_SCREEN* screen = m_frame->GetScreen();
|
2019-11-26 20:46:07 +01:00
|
|
|
int index;
|
2019-07-26 17:52:17 -06:00
|
|
|
wxString msg;
|
2019-11-26 20:46:07 +01:00
|
|
|
wxString searchString;
|
2020-12-16 19:24:31 +02:00
|
|
|
bool endIsReached = false;
|
|
|
|
bool isFirstSearch = false;
|
2019-07-26 17:52:17 -06:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
searchString = m_searchCombo->GetValue();
|
2022-01-18 18:59:04 +00:00
|
|
|
|
|
|
|
if( searchString.IsEmpty() )
|
|
|
|
{
|
|
|
|
Show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add/move the search string to the top of the list if it isn't already there
|
2019-11-26 20:46:07 +01:00
|
|
|
index = m_searchCombo->FindString( searchString, true );
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2019-07-26 23:50:51 -06:00
|
|
|
if( index == wxNOT_FOUND )
|
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
m_searchCombo->Insert( searchString, 0 );
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
2019-12-10 05:49:28 -08:00
|
|
|
m_upToDate = false;
|
2019-11-26 20:46:07 +01:00
|
|
|
m_frame->GetFindHistoryList().Insert( searchString, 0 );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
if( m_searchCombo->GetCount() > 10 )
|
|
|
|
{
|
|
|
|
m_frame->GetFindHistoryList().pop_back();
|
|
|
|
m_searchCombo->Delete( 10 );
|
|
|
|
}
|
2019-07-26 23:50:51 -06:00
|
|
|
}
|
|
|
|
else if( index != 0 )
|
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
m_searchCombo->Delete( index );
|
|
|
|
m_searchCombo->Insert( searchString, 0 );
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
2019-12-10 05:49:28 -08:00
|
|
|
m_upToDate = false;
|
2019-11-26 20:46:07 +01:00
|
|
|
|
|
|
|
if( m_frame->GetFindHistoryList().Index( searchString ) )
|
|
|
|
m_frame->GetFindHistoryList().Remove( searchString );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
m_frame->GetFindHistoryList().Insert( searchString, 0 );
|
2019-07-26 23:50:51 -06:00
|
|
|
}
|
2019-11-30 01:00:16 +00:00
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
EDA_SEARCH_DATA& frd = m_frame->GetFindReplaceData();
|
2019-11-26 20:46:07 +01:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_matchCase->GetValue() )
|
2025-04-07 21:10:45 +01:00
|
|
|
frd.matchCase = true;
|
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_matchWords->GetValue() )
|
2025-04-07 21:10:45 +01:00
|
|
|
frd.matchMode = EDA_SEARCH_MATCH_MODE::WHOLEWORD;
|
2025-08-07 14:16:14 +01:00
|
|
|
else if( m_wildcards->GetValue() )
|
2025-04-07 21:10:45 +01:00
|
|
|
frd.matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
2022-08-04 22:40:38 -04:00
|
|
|
else
|
2025-04-07 21:10:45 +01:00
|
|
|
frd.matchMode = EDA_SEARCH_MATCH_MODE::PLAIN;
|
2018-09-19 12:30:04 -04:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
frd.searchAllFields = m_checkAllFields->GetValue();
|
2025-05-11 11:33:16 +01:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
// Search parameters
|
2025-04-07 21:10:45 +01:00
|
|
|
frd.findString = searchString;
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2025-04-02 11:01:22 -04:00
|
|
|
m_frame->GetToolManager()->RunAction( ACTIONS::selectionClear );
|
2019-07-26 17:52:17 -06:00
|
|
|
m_frame->GetCanvas()->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y );
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
2019-11-30 01:00:16 +00:00
|
|
|
// Refresh the list of results
|
2019-12-10 05:49:28 -08:00
|
|
|
if( !m_upToDate )
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
2019-11-29 21:38:18 +00:00
|
|
|
m_status->SetLabel( _( "Searching..." ) );
|
2019-12-10 05:49:28 -08:00
|
|
|
m_hitList.clear();
|
2012-05-28 23:01:51 +03:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_includeTexts->GetValue() || m_includeValues->GetValue() || m_includeReferences->GetValue() )
|
2019-07-26 17:52:17 -06:00
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( FOOTPRINT* fp : board->Footprints() )
|
2019-07-26 17:52:17 -06:00
|
|
|
{
|
2025-04-07 21:10:45 +01:00
|
|
|
bool found = false;
|
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_includeReferences->GetValue() && fp->Reference().Matches( frd, nullptr ) )
|
2025-04-07 21:10:45 +01:00
|
|
|
found = true;
|
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( !found && m_includeValues->GetValue() && fp->Value().Matches( frd, nullptr ) )
|
2025-04-07 21:10:45 +01:00
|
|
|
found = true;
|
2019-07-26 17:52:17 -06:00
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
if( !found && m_includeTexts->GetValue() )
|
2019-07-26 17:52:17 -06:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
for( BOARD_ITEM* item : fp->GraphicalItems() )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
2023-03-30 12:49:23 +01:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
2023-03-30 12:49:23 +01:00
|
|
|
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
if( text->Matches( frd, nullptr ) )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
|
|
|
}
|
2025-04-07 21:10:45 +01:00
|
|
|
}
|
2023-06-06 11:09:34 -04:00
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
if( !found && m_includeTexts->GetValue() )
|
|
|
|
{
|
2024-12-28 20:40:57 +00:00
|
|
|
for( PCB_FIELD* field : fp->GetFields() )
|
2023-06-06 11:09:34 -04:00
|
|
|
{
|
2025-04-07 21:10:45 +01:00
|
|
|
if( field->Matches( frd, nullptr ) )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
2023-06-06 11:09:34 -04:00
|
|
|
}
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
2025-04-07 21:10:45 +01:00
|
|
|
|
|
|
|
if( found )
|
|
|
|
m_hitList.push_back( fp );
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_includeTexts->GetValue() )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( BOARD_ITEM* item : board->Drawings() )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
2023-03-30 12:49:23 +01:00
|
|
|
if( item->Type() == PCB_TEXT_T )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
2023-03-30 12:49:23 +01:00
|
|
|
PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
|
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
if( text && text->Matches( frd, nullptr ) )
|
2023-03-30 12:49:23 +01:00
|
|
|
m_hitList.push_back( text );
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
2019-07-26 17:52:17 -06:00
|
|
|
}
|
2021-01-07 02:53:55 +08:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
for( BOARD_ITEM* item : board->Zones() )
|
2021-01-07 02:53:55 +08:00
|
|
|
{
|
2023-03-30 12:49:23 +01:00
|
|
|
ZONE* zone = static_cast<ZONE*>( item );
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2025-04-07 21:10:45 +01:00
|
|
|
if( zone->Matches( frd, nullptr ) )
|
2023-03-30 12:49:23 +01:00
|
|
|
m_hitList.push_back( zone );
|
2021-01-07 02:53:55 +08:00
|
|
|
}
|
2019-07-26 17:52:17 -06:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_includeMarkers->GetValue() )
|
2019-11-28 01:18:20 +01:00
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( PCB_MARKER* marker : board->Markers() )
|
2019-11-28 01:18:20 +01:00
|
|
|
{
|
2025-04-07 21:10:45 +01:00
|
|
|
if( marker->Matches( frd, nullptr ) )
|
2019-12-10 05:49:28 -08:00
|
|
|
m_hitList.push_back( marker );
|
2019-11-28 01:18:20 +01:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2025-08-07 14:16:14 +01:00
|
|
|
if( m_includeNets->GetValue() )
|
2022-03-10 23:12:30 +00:00
|
|
|
{
|
|
|
|
for( NETINFO_ITEM* net : board->GetNetInfo() )
|
|
|
|
{
|
2025-04-07 21:10:45 +01:00
|
|
|
if( net && net->Matches( frd, nullptr ) )
|
2022-03-10 23:12:30 +00:00
|
|
|
m_hitList.push_back( net );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 05:49:28 -08:00
|
|
|
m_upToDate = true;
|
2020-12-16 19:24:31 +02:00
|
|
|
isFirstSearch = true;
|
2019-12-10 05:49:28 -08:00
|
|
|
|
|
|
|
if( aDirection )
|
|
|
|
m_it = m_hitList.begin();
|
|
|
|
else
|
|
|
|
m_it = m_hitList.end();
|
2019-07-26 17:52:17 -06:00
|
|
|
}
|
2019-11-30 01:00:16 +00:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
// Do we want a sorting algorithm ? If so, implement it here.
|
2019-07-26 17:52:17 -06:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
// Get the item to display
|
2019-12-10 05:49:28 -08:00
|
|
|
if( m_hitList.empty() )
|
2019-07-26 17:52:17 -06:00
|
|
|
{
|
2019-11-26 20:46:07 +01:00
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
|
|
|
}
|
2020-12-16 19:24:31 +02:00
|
|
|
else
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
|
|
|
if( aDirection )
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
2020-12-16 19:24:31 +02:00
|
|
|
if( m_it != m_hitList.end() && !isFirstSearch )
|
|
|
|
m_it++;
|
2019-12-10 05:49:28 -08:00
|
|
|
|
|
|
|
if( m_it == m_hitList.end() )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
|
|
|
if( m_wrap->GetValue() )
|
2020-12-16 19:24:31 +02:00
|
|
|
{
|
2019-12-10 05:49:28 -08:00
|
|
|
m_it = m_hitList.begin();
|
2020-12-16 19:24:31 +02:00
|
|
|
}
|
2019-11-26 20:46:07 +01:00
|
|
|
else
|
|
|
|
{
|
2020-12-16 19:24:31 +02:00
|
|
|
endIsReached = true;
|
|
|
|
m_it--; // point to the last REAL result
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-10 05:49:28 -08:00
|
|
|
if( m_it == m_hitList.begin() )
|
2019-11-26 20:46:07 +01:00
|
|
|
{
|
|
|
|
if( m_wrap->GetValue() )
|
2019-12-10 05:49:28 -08:00
|
|
|
m_it = m_hitList.end();
|
2019-11-26 20:46:07 +01:00
|
|
|
else
|
2020-12-16 19:24:31 +02:00
|
|
|
endIsReached = true;
|
2019-11-26 20:46:07 +01:00
|
|
|
}
|
2019-12-10 05:49:28 -08:00
|
|
|
|
2020-12-16 19:24:31 +02:00
|
|
|
if( m_it != m_hitList.begin() )
|
|
|
|
m_it--;
|
2012-05-28 23:01:51 +03:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 20:46:07 +01:00
|
|
|
// Display the item
|
2020-12-16 19:24:31 +02:00
|
|
|
if( m_hitList.empty() )
|
|
|
|
{
|
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
2021-06-29 00:44:07 +01:00
|
|
|
msg.Printf( _( "'%s' not found" ), searchString );
|
2020-12-16 19:24:31 +02:00
|
|
|
m_frame->ShowInfoBarMsg( msg );
|
2021-01-07 03:14:36 +08:00
|
|
|
|
|
|
|
m_status->SetLabel( msg );
|
2020-12-16 19:24:31 +02:00
|
|
|
}
|
2025-06-05 13:58:06 +01:00
|
|
|
else if( endIsReached || m_it == m_hitList.end() )
|
2020-12-16 19:24:31 +02:00
|
|
|
{
|
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
|
|
|
m_frame->ShowInfoBarMsg( _( "No more items to show" ) );
|
|
|
|
|
|
|
|
m_status->SetLabel( _( "No hits" ) );
|
|
|
|
}
|
|
|
|
else
|
2012-05-28 23:01:51 +03:00
|
|
|
{
|
2025-04-02 11:01:22 -04:00
|
|
|
m_frame->GetToolManager()->RunAction<EDA_ITEM*>( ACTIONS::selectItem, *m_it );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2021-06-29 00:44:07 +01:00
|
|
|
msg.Printf( _( "'%s' found" ), searchString );
|
2019-07-26 17:52:17 -06:00
|
|
|
m_frame->SetStatusText( msg );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2023-05-29 16:49:36 +02:00
|
|
|
msg.Printf( _( "Hit(s): %d / %zu" ),
|
|
|
|
(int)std::distance( m_hitList.begin(), m_it ) + 1,
|
2021-06-29 00:44:07 +01:00
|
|
|
m_hitList.size() );
|
2019-11-29 21:38:18 +00:00
|
|
|
m_status->SetLabel( msg );
|
2012-05-28 23:01:51 +03:00
|
|
|
}
|
2014-10-13 15:23:30 +02:00
|
|
|
|
2019-07-26 17:52:17 -06:00
|
|
|
if( m_highlightCallback )
|
2019-12-10 05:49:28 -08:00
|
|
|
m_highlightCallback( GetItem() );
|
2012-05-28 23:01:51 +03:00
|
|
|
}
|
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2021-12-06 19:08:23 +00:00
|
|
|
bool DIALOG_FIND::Show( bool show )
|
|
|
|
{
|
|
|
|
bool ret = DIALOG_FIND_BASE::Show( show );
|
|
|
|
|
|
|
|
if( show )
|
|
|
|
m_searchCombo->SetFocus();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-07-21 17:37:49 -04:00
|
|
|
|
2025-08-06 16:36:35 -07:00
|
|
|
void DIALOG_FIND::OnBoardChanged( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_board = m_frame->GetBoard();
|
|
|
|
|
|
|
|
if( m_board )
|
|
|
|
m_board->AddListener( this );
|
|
|
|
|
|
|
|
m_upToDate = false;
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|