2012-05-28 20:01:51 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2012-05-29 20:43:17 +00:00
|
|
|
* Copyright (C) 2012 Marco Mattila <marcom99@gmail.com>
|
2018-01-17 14:36:04 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2022-03-10 23:12:30 +00:00
|
|
|
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
|
2012-05-28 20:01:51 +00: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
|
|
|
|
*/
|
|
|
|
|
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-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
|
|
|
#include <fp_text.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <zone.h>
|
2019-11-26 19:46:07 +00:00
|
|
|
#include <dialog_find.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2019-11-26 19:46:07 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <string>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2019-07-26 23:52:17 +00:00
|
|
|
#include <wx/fdrepdlg.h>
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
//Defined as global because these values have to survive the destructor
|
|
|
|
|
|
|
|
bool FindOptionCase = false;
|
|
|
|
bool FindOptionWords = false;
|
|
|
|
bool FindOptionWildcards = false;
|
|
|
|
bool FindOptionWrap = true;
|
|
|
|
|
|
|
|
bool FindIncludeTexts = true;
|
|
|
|
bool FindIncludeValues = true;
|
|
|
|
bool FindIncludeReferences = true;
|
2019-11-28 00:18:20 +00:00
|
|
|
bool FindIncludeMarkers = true;
|
2022-03-10 23:12:30 +00:00
|
|
|
bool FindIncludeNets = true;
|
2019-12-10 13:49:28 +00:00
|
|
|
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2021-10-18 20:43:44 +00:00
|
|
|
DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME *aFrame ) :
|
|
|
|
DIALOG_FIND_BASE( aFrame, wxID_ANY, _( "Find" ) )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-07-26 23:52:17 +00:00
|
|
|
m_frame = aFrame;
|
2012-05-28 20:01:51 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
m_searchCombo->Append( m_frame->GetFindHistoryList() );
|
2019-07-26 23:52:17 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
while( m_searchCombo->GetCount() > 10 )
|
2019-07-26 23:52:17 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
m_frame->GetFindHistoryList().pop_back();
|
|
|
|
m_searchCombo->Delete( 9 );
|
2019-07-26 23:52:17 +00:00
|
|
|
}
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( m_searchCombo->GetCount() )
|
|
|
|
{
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
|
|
|
m_searchCombo->SelectAll();
|
|
|
|
}
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
m_matchCase->SetValue( FindOptionCase );
|
|
|
|
m_matchWords->SetValue( FindOptionWords );
|
|
|
|
m_wildcards->SetValue( FindOptionWildcards );
|
|
|
|
m_wrap->SetValue( FindOptionWrap );
|
|
|
|
|
|
|
|
m_includeTexts->SetValue( FindIncludeTexts );
|
|
|
|
m_includeValues->SetValue( FindIncludeValues );
|
|
|
|
m_includeReferences->SetValue( FindIncludeReferences );
|
2019-11-28 00:18:20 +00:00
|
|
|
m_includeMarkers->SetValue( FindIncludeMarkers );
|
2022-03-10 23:12:30 +00:00
|
|
|
m_includeNets->SetValue( FindIncludeNets );
|
2019-11-26 19:46:07 +00:00
|
|
|
|
2019-11-30 01:00:16 +00:00
|
|
|
m_status->SetLabel( wxEmptyString);
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
|
|
|
|
|
|
|
m_hitList.clear();
|
|
|
|
m_it = m_hitList.begin();
|
2019-11-30 01:00:16 +00:00
|
|
|
|
|
|
|
m_findNext->SetDefault();
|
2019-11-26 19:46:07 +00:00
|
|
|
SetInitialFocus( m_searchCombo );
|
2018-09-19 16:30:04 +00:00
|
|
|
|
2019-07-26 23:52:17 +00:00
|
|
|
Center();
|
2017-01-22 21:51:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
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 19:46:07 +00:00
|
|
|
void DIALOG_FIND::onTextEnter( wxCommandEvent& aEvent )
|
2014-10-13 13:23:30 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
search( true );
|
2014-10-13 13:23:30 +00:00
|
|
|
}
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
search( true );
|
|
|
|
}
|
2018-09-19 16:30:04 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
search( false );
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
search( true );
|
|
|
|
}
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
void DIALOG_FIND::search( bool aDirection )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-07-26 23:52:17 +00:00
|
|
|
PCB_SCREEN* screen = m_frame->GetScreen();
|
2019-11-26 19:46:07 +00:00
|
|
|
int index;
|
2019-07-26 23:52:17 +00:00
|
|
|
wxString msg;
|
2019-11-26 19:46:07 +00:00
|
|
|
wxString searchString;
|
2020-12-16 17:24:31 +00:00
|
|
|
bool endIsReached = false;
|
|
|
|
bool isFirstSearch = false;
|
2019-07-26 23:52:17 +00:00
|
|
|
|
2019-11-26 19:46:07 +00: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 19:46:07 +00:00
|
|
|
index = m_searchCombo->FindString( searchString, true );
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2019-07-27 05:50:51 +00:00
|
|
|
if( index == wxNOT_FOUND )
|
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
m_searchCombo->Insert( searchString, 0 );
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
m_frame->GetFindHistoryList().Insert( searchString, 0 );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( m_searchCombo->GetCount() > 10 )
|
|
|
|
{
|
|
|
|
m_frame->GetFindHistoryList().pop_back();
|
|
|
|
m_searchCombo->Delete( 10 );
|
|
|
|
}
|
2019-07-27 05:50:51 +00:00
|
|
|
}
|
|
|
|
else if( index != 0 )
|
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
m_searchCombo->Delete( index );
|
|
|
|
m_searchCombo->Insert( searchString, 0 );
|
|
|
|
m_searchCombo->SetSelection( 0 );
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
|
|
|
|
if( m_frame->GetFindHistoryList().Index( searchString ) )
|
|
|
|
m_frame->GetFindHistoryList().Remove( searchString );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
m_frame->GetFindHistoryList().Insert( searchString, 0 );
|
2019-07-27 05:50:51 +00:00
|
|
|
}
|
2019-11-30 01:00:16 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindOptionCase != m_matchCase->GetValue() )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
FindOptionCase = m_matchCase->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindOptionWords != m_matchWords->GetValue() )
|
|
|
|
{
|
|
|
|
FindOptionWords = m_matchWords->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindOptionWildcards != m_wildcards->GetValue() )
|
|
|
|
{
|
|
|
|
FindOptionWildcards = m_wildcards->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
FindOptionWrap = m_wrap->GetValue();
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindIncludeTexts != m_includeTexts->GetValue() )
|
|
|
|
{
|
|
|
|
FindIncludeTexts = m_includeTexts->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindIncludeValues != m_includeValues->GetValue() )
|
|
|
|
{
|
|
|
|
FindIncludeValues = m_includeValues->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindIncludeReferences != m_includeReferences->GetValue() )
|
|
|
|
{
|
|
|
|
FindIncludeReferences = m_includeReferences->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-28 00:18:20 +00:00
|
|
|
if( FindIncludeMarkers != m_includeMarkers->GetValue() )
|
|
|
|
{
|
|
|
|
FindIncludeMarkers = m_includeMarkers->GetValue();
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = false;
|
2019-11-28 00:18:20 +00:00
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
if( FindIncludeNets != m_includeNets->GetValue() )
|
|
|
|
{
|
|
|
|
FindIncludeNets = m_includeNets->GetValue();
|
|
|
|
m_upToDate = false;
|
|
|
|
}
|
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindOptionCase )
|
2022-08-05 02:40:38 +00:00
|
|
|
m_frame->GetFindReplaceData().matchCase = true;
|
2019-11-26 19:46:07 +00:00
|
|
|
|
|
|
|
if( FindOptionWords )
|
2022-08-05 02:40:38 +00:00
|
|
|
m_frame->GetFindReplaceData().matchMode = EDA_SEARCH_MATCH_MODE::WHOLEWORD;
|
|
|
|
else if( FindOptionWildcards )
|
|
|
|
m_frame->GetFindReplaceData().matchMode = EDA_SEARCH_MATCH_MODE::WILDCARD;
|
|
|
|
else
|
|
|
|
m_frame->GetFindReplaceData().matchMode = EDA_SEARCH_MATCH_MODE::PLAIN;
|
2018-09-19 16:30:04 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
// Search parameters
|
2022-08-05 02:40:38 +00:00
|
|
|
m_frame->GetFindReplaceData().findString = searchString;
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2019-07-27 05:50:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
2019-07-26 23:52:17 +00:00
|
|
|
m_frame->GetCanvas()->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y );
|
2012-05-28 20:01:51 +00: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 13:49:28 +00:00
|
|
|
if( !m_upToDate )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-11-29 21:38:18 +00:00
|
|
|
m_status->SetLabel( _( "Searching..." ) );
|
2019-12-10 13:49:28 +00:00
|
|
|
m_hitList.clear();
|
2012-05-28 20:01:51 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindIncludeTexts || FindIncludeValues || FindIncludeReferences )
|
2019-07-26 23:52:17 +00:00
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( FOOTPRINT* fp : board->Footprints() )
|
2019-07-26 23:52:17 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
if( ( fp->Reference().Matches( m_frame->GetFindReplaceData(), nullptr )
|
|
|
|
&& FindIncludeReferences )
|
|
|
|
|| ( fp->Value().Matches( m_frame->GetFindReplaceData(), nullptr )
|
|
|
|
&& FindIncludeValues ) )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
m_hitList.push_back( fp );
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-07-26 23:52:17 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( m_includeTexts->GetValue() )
|
2019-07-26 23:52:17 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
for( BOARD_ITEM* item : fp->GraphicalItems() )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
FP_TEXT* textItem = dynamic_cast<FP_TEXT*>( item );
|
2019-11-26 19:46:07 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
if( textItem && textItem->Matches( m_frame->GetFindReplaceData(),
|
|
|
|
nullptr ) )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
2020-11-12 23:50:33 +00:00
|
|
|
m_hitList.push_back( fp );
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
if( FindIncludeTexts )
|
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( BOARD_ITEM* item : board->Drawings() )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
2020-10-04 23:34:59 +00:00
|
|
|
PCB_TEXT* textItem = dynamic_cast<PCB_TEXT*>( item );
|
2019-11-26 19:46:07 +00:00
|
|
|
|
|
|
|
if( textItem && textItem->Matches( m_frame->GetFindReplaceData(), nullptr ) )
|
|
|
|
{
|
2019-12-10 13:49:28 +00:00
|
|
|
m_hitList.push_back( textItem );
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-07-26 23:52:17 +00:00
|
|
|
}
|
2021-01-06 18:53:55 +00:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
for( BOARD_ITEM* item : board->Zones() )
|
2021-01-06 18:53:55 +00:00
|
|
|
{
|
|
|
|
ZONE* zoneItem = dynamic_cast<ZONE*>( item );
|
2021-07-21 21:37:49 +00:00
|
|
|
|
2021-01-06 18:53:55 +00:00
|
|
|
if( zoneItem && zoneItem->Matches( m_frame->GetFindReplaceData(), nullptr ) )
|
|
|
|
{
|
|
|
|
m_hitList.push_back( zoneItem );
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 23:52:17 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-28 00:18:20 +00:00
|
|
|
if( FindIncludeMarkers )
|
|
|
|
{
|
2022-03-10 23:12:30 +00:00
|
|
|
for( PCB_MARKER* marker : board->Markers() )
|
2019-11-28 00:18:20 +00:00
|
|
|
{
|
|
|
|
if( marker->Matches( m_frame->GetFindReplaceData(), nullptr ) )
|
2019-12-10 13:49:28 +00:00
|
|
|
m_hitList.push_back( marker );
|
2019-11-28 00:18:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2022-03-10 23:12:30 +00:00
|
|
|
if( FindIncludeNets )
|
|
|
|
{
|
|
|
|
for( NETINFO_ITEM* net : board->GetNetInfo() )
|
|
|
|
{
|
|
|
|
if( net && net->Matches( m_frame->GetFindReplaceData(), nullptr ) )
|
|
|
|
{
|
|
|
|
m_hitList.push_back( net );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 13:49:28 +00:00
|
|
|
m_upToDate = true;
|
2020-12-16 17:24:31 +00:00
|
|
|
isFirstSearch = true;
|
2019-12-10 13:49:28 +00:00
|
|
|
|
|
|
|
if( aDirection )
|
|
|
|
m_it = m_hitList.begin();
|
|
|
|
else
|
|
|
|
m_it = m_hitList.end();
|
2019-07-26 23:52:17 +00:00
|
|
|
}
|
2019-11-30 01:00:16 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
// Do we want a sorting algorithm ? If so, implement it here.
|
2019-07-26 23:52:17 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
// Get the item to display
|
2019-12-10 13:49:28 +00:00
|
|
|
if( m_hitList.empty() )
|
2019-07-26 23:52:17 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
|
|
|
}
|
2020-12-16 17:24:31 +00:00
|
|
|
else
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
|
|
|
if( aDirection )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2020-12-16 17:24:31 +00:00
|
|
|
if( m_it != m_hitList.end() && !isFirstSearch )
|
|
|
|
m_it++;
|
2019-12-10 13:49:28 +00:00
|
|
|
|
|
|
|
if( m_it == m_hitList.end() )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
|
|
|
if( m_wrap->GetValue() )
|
2020-12-16 17:24:31 +00:00
|
|
|
{
|
2019-12-10 13:49:28 +00:00
|
|
|
m_it = m_hitList.begin();
|
2020-12-16 17:24:31 +00:00
|
|
|
}
|
2019-11-26 19:46:07 +00:00
|
|
|
else
|
|
|
|
{
|
2020-12-16 17:24:31 +00:00
|
|
|
endIsReached = true;
|
|
|
|
m_it--; // point to the last REAL result
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-10 13:49:28 +00:00
|
|
|
if( m_it == m_hitList.begin() )
|
2019-11-26 19:46:07 +00:00
|
|
|
{
|
|
|
|
if( m_wrap->GetValue() )
|
2019-12-10 13:49:28 +00:00
|
|
|
m_it = m_hitList.end();
|
2019-11-26 19:46:07 +00:00
|
|
|
else
|
2020-12-16 17:24:31 +00:00
|
|
|
endIsReached = true;
|
2019-11-26 19:46:07 +00:00
|
|
|
}
|
2019-12-10 13:49:28 +00:00
|
|
|
|
2020-12-16 17:24:31 +00:00
|
|
|
if( m_it != m_hitList.begin() )
|
|
|
|
m_it--;
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2019-11-26 19:46:07 +00:00
|
|
|
// Display the item
|
2020-12-16 17:24:31 +00:00
|
|
|
if( m_hitList.empty() )
|
|
|
|
{
|
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "'%s' not found" ), searchString );
|
2020-12-16 17:24:31 +00:00
|
|
|
m_frame->ShowInfoBarMsg( msg );
|
2021-01-06 19:14:36 +00:00
|
|
|
|
|
|
|
m_status->SetLabel( msg );
|
2020-12-16 17:24:31 +00:00
|
|
|
}
|
2020-12-16 22:01:32 +00:00
|
|
|
else if( endIsReached )
|
2020-12-16 17:24:31 +00:00
|
|
|
{
|
|
|
|
m_frame->SetStatusText( wxEmptyString );
|
|
|
|
m_frame->ShowInfoBarMsg( _( "No more items to show" ) );
|
|
|
|
|
|
|
|
m_status->SetLabel( _( "No hits" ) );
|
|
|
|
}
|
|
|
|
else
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-12-10 13:49:28 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, *m_it );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "'%s' found" ), searchString );
|
2019-07-26 23:52:17 +00:00
|
|
|
m_frame->SetStatusText( msg );
|
2019-11-29 21:38:18 +00:00
|
|
|
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "Hit(s): %ld / %lu" ),
|
|
|
|
std::distance( m_hitList.begin(), m_it ) + 1,
|
|
|
|
m_hitList.size() );
|
2019-11-29 21:38:18 +00:00
|
|
|
m_status->SetLabel( msg );
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|
2014-10-13 13:23:30 +00:00
|
|
|
|
2019-07-26 23:52:17 +00:00
|
|
|
if( m_highlightCallback )
|
2019-12-10 13:49:28 +00:00
|
|
|
m_highlightCallback( GetItem() );
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
void DIALOG_FIND::OnCloseButtonClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxCloseEvent tmp;
|
|
|
|
|
|
|
|
OnClose( tmp );
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
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 21:37:49 +00:00
|
|
|
|
|
|
|
void DIALOG_FIND::OnClose( wxCloseEvent& aEvent )
|
2012-05-28 20:01:51 +00:00
|
|
|
{
|
2019-11-26 19:46:07 +00:00
|
|
|
FindOptionCase = m_matchCase->GetValue();
|
|
|
|
FindOptionWords = m_matchWords->GetValue();
|
|
|
|
FindOptionWildcards = m_wildcards->GetValue();
|
|
|
|
FindOptionWrap = m_wrap->GetValue();
|
|
|
|
|
|
|
|
FindIncludeTexts = m_includeTexts->GetValue();
|
|
|
|
FindIncludeValues = m_includeValues->GetValue();
|
2019-11-28 00:18:20 +00:00
|
|
|
FindIncludeMarkers = m_includeMarkers->GetValue();
|
2019-11-26 19:46:07 +00:00
|
|
|
FindIncludeReferences = m_includeReferences->GetValue();
|
2022-03-10 23:12:30 +00:00
|
|
|
FindIncludeNets = m_includeNets->GetValue();
|
2019-11-26 19:46:07 +00:00
|
|
|
|
2021-07-21 21:37:49 +00:00
|
|
|
aEvent.Skip();
|
2012-05-28 20:01:51 +00:00
|
|
|
}
|