Some cleanup for the Pcbnew search changes.

This commit is contained in:
Jeff Young 2019-11-29 21:38:18 +00:00
parent 7297822423
commit 1e4437c6df
4 changed files with 65 additions and 80 deletions

View File

@ -135,6 +135,7 @@ void DIALOG_FIND::search( bool aDirection )
m_searchCombo->SetSelection( 0 );
isUpToDate = false;
m_frame->GetFindHistoryList().Insert( searchString, 0 );
if( m_searchCombo->GetCount() > 10 )
{
m_frame->GetFindHistoryList().pop_back();
@ -150,6 +151,7 @@ void DIALOG_FIND::search( bool aDirection )
if( m_frame->GetFindHistoryList().Index( searchString ) )
m_frame->GetFindHistoryList().Remove( searchString );
m_frame->GetFindHistoryList().Insert( searchString, 0 );
}
// Update search flags
@ -160,37 +162,45 @@ void DIALOG_FIND::search( bool aDirection )
FindOptionCase = m_matchCase->GetValue();
isUpToDate = false;
}
if( FindOptionWords != m_matchWords->GetValue() )
{
FindOptionWords = m_matchWords->GetValue();
isUpToDate = false;
}
if( FindOptionWildcards != m_wildcards->GetValue() )
{
FindOptionWildcards = m_wildcards->GetValue();
isUpToDate = false;
}
FindOptionWrap = m_wrap->GetValue();
if( FindIncludeTexts != m_includeTexts->GetValue() )
{
FindIncludeTexts = m_includeTexts->GetValue();
isUpToDate = false;
}
if( FindIncludeValues != m_includeValues->GetValue() )
{
FindIncludeValues = m_includeValues->GetValue();
isUpToDate = false;
}
if( FindIncludeReferences != m_includeReferences->GetValue() )
{
FindIncludeReferences = m_includeReferences->GetValue();
isUpToDate = false;
}
if( FindIncludeMarkers != m_includeMarkers->GetValue() )
{
FindIncludeMarkers = m_includeMarkers->GetValue();
isUpToDate = false;
}
if( FindOptionCase )
flags |= wxFR_MATCHCASE;
@ -210,9 +220,11 @@ void DIALOG_FIND::search( bool aDirection )
if( !isUpToDate )
{
m_status->SetValue( "Searching..." );
m_status->SetLabel( _( "Searching..." ) );
while( m_hitList->GetCount() > 0 )
m_hitList->PopBack();
m_foundItem = NULL;
if( FindIncludeTexts || FindIncludeValues || FindIncludeReferences )
@ -241,6 +253,7 @@ void DIALOG_FIND::search( bool aDirection )
}
}
}
if( FindIncludeTexts )
{
for( BOARD_ITEM* item : m_frame->GetBoard()->Drawings() )
@ -254,16 +267,18 @@ void DIALOG_FIND::search( bool aDirection )
}
}
}
if( FindIncludeMarkers )
{
int i;
for( i = 0; i < m_frame->GetBoard()->GetMARKERCount(); ++i )
for( int i = 0; i < m_frame->GetBoard()->GetMARKERCount(); ++i )
{
MARKER_PCB* marker = m_frame->GetBoard()->GetMARKER( i );
if( marker->Matches( m_frame->GetFindReplaceData(), nullptr ) )
m_hitList->Append( marker );
}
}
m_cancel->Show( false );
m_gauge->Show( false );
m_status->Show( true );
@ -282,7 +297,7 @@ void DIALOG_FIND::search( bool aDirection )
else if( m_itemCount == -1 )
{
m_foundItem = aDirection ? m_hitList->begin() : m_hitList->end();
m_itemCount = aDirection ? 0 : m_hitList->GetCount() - 1;
m_itemCount = aDirection ? 0 : (int) m_hitList->GetCount() - 1;
isUpToDate = true;
}
else
@ -299,8 +314,7 @@ void DIALOG_FIND::search( bool aDirection )
else
{
m_frame->SetStatusText( wxEmptyString );
msg.Printf( _( "No more item to show" ), GetChars( searchString ) );
DisplayError( this, msg, 10 );
DisplayError( this, _( "No more item to show" ), 10 );
return;
}
}
@ -316,14 +330,13 @@ void DIALOG_FIND::search( bool aDirection )
{
if( m_wrap->GetValue() )
{
m_itemCount = m_hitList->GetCount() - 1;
m_itemCount = (int) m_hitList->GetCount() - 1;
m_foundItem = m_hitList->end();
}
else
{
m_frame->SetStatusText( wxEmptyString );
msg.Printf( _( "No more item to show" ), GetChars( searchString ) );
DisplayError( this, msg, 10 );
DisplayError( this, _( "No more item to show" ), 10 );
return;
}
}
@ -334,24 +347,28 @@ void DIALOG_FIND::search( bool aDirection )
}
}
}
// Display the item
if( m_foundItem )
{
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectItem, true, m_foundItem );
m_frame->FocusOnLocation( m_foundItem->GetPosition(), true );
msg.Printf( _( "\"%s\" found" ), GetChars( searchString ) );
msg.Printf( _( "\"%s\" found" ), searchString );
m_frame->SetStatusText( msg );
msg = wxEmptyString;
msg = msg << "Hit(s): " << m_itemCount + 1 << " / " << m_hitList->GetCount();
m_status->SetValue( msg );
msg.Printf( _( "Hit(s): %i / %i" ), m_itemCount + 1, m_hitList->GetCount() );
m_status->SetLabel( msg );
}
else
{
m_frame->SetStatusText( wxEmptyString );
msg.Printf( _( "\"%s\" not found" ), GetChars( searchString ) );
msg.Printf( _( "\"%s\" not found" ), searchString );
DisplayError( this, msg, 10 );
m_itemCount = 0;
m_status->SetValue( "No hit" );
m_status->SetLabel( _( "No hits" ) );
}
if( m_highlightCallback )
@ -372,6 +389,7 @@ void DIALOG_FIND::onClose( wxCloseEvent& aEvent )
while( m_hitList->GetCount() > 0 )
m_hitList->PopBack();
delete m_hitList;
EndModal( 1 );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Nov 22 2019)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -12,8 +12,7 @@
DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
this->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxVERTICAL );
@ -29,13 +28,10 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr
staticText1 = new wxStaticText( this, wxID_ANY, wxT("Search for :"), wxDefaultPosition, wxDefaultSize, 0 );
staticText1->Wrap( -1 );
staticText1->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
bSizer8->Add( staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_searchCombo = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER );
m_searchCombo->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
m_searchCombo->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
m_searchCombo->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
bSizer8->Add( m_searchCombo, 1, wxALL|wxEXPAND, 5 );
@ -46,24 +42,16 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr
sizerOptions = new wxBoxSizer( wxHORIZONTAL );
m_matchCase = new wxCheckBox( this, wxID_ANY, wxT("Match case"), wxDefaultPosition, wxDefaultSize, 0 );
m_matchCase->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerOptions->Add( m_matchCase, 0, wxALL, 5 );
m_matchWords = new wxCheckBox( this, wxID_ANY, wxT("Words"), wxDefaultPosition, wxDefaultSize, 0 );
m_matchWords->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerOptions->Add( m_matchWords, 0, wxALL, 5 );
m_wildcards = new wxCheckBox( this, wxID_ANY, wxT("Wildcards"), wxDefaultPosition, wxDefaultSize, 0 );
m_wildcards->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerOptions->Add( m_wildcards, 0, wxALL, 5 );
m_wrap = new wxCheckBox( this, wxID_ANY, wxT("Wrap"), wxDefaultPosition, wxDefaultSize, 0 );
m_wrap->SetValue(true);
m_wrap->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerOptions->Add( m_wrap, 0, wxALL, 5 );
@ -74,31 +62,22 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_includeTexts = new wxCheckBox( this, wxID_ANY, wxT("Search for texts"), wxDefaultPosition, wxDefaultSize, 0 );
m_includeTexts->SetValue(true);
m_includeTexts->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerInclude->Add( m_includeTexts, 0, wxALL, 5 );
m_includeValues = new wxCheckBox( this, wxID_ANY, wxT("Search for item values"), wxDefaultPosition, wxDefaultSize, 0 );
m_includeValues->SetValue(true);
m_includeValues->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerInclude->Add( m_includeValues, 0, wxALL, 5 );
m_includeReferences = new wxCheckBox( this, wxID_ANY, wxT("Search for item references"), wxDefaultPosition, wxDefaultSize, 0 );
m_includeReferences->SetValue(true);
m_includeReferences->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerInclude->Add( m_includeReferences, 0, wxALL, 5 );
m_includeMarkers = new wxCheckBox( this, wxID_ANY, wxT("Search for DRC markers"), wxDefaultPosition, wxDefaultSize, 0 );
m_includeMarkers->SetValue(true);
m_includeMarkers->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
sizerInclude->Add( m_includeMarkers, 0, wxALL, 5 );
m_includeVias = new wxCheckBox( this, wxID_ANY, wxT("Vias"), wxDefaultPosition, wxDefaultSize, 0 );
m_includeVias->SetValue(true);
m_includeVias->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
m_includeVias->Hide();
sizerInclude->Add( m_includeVias, 0, wxALL, 5 );
@ -130,11 +109,9 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr
wxBoxSizer* sizerStatus;
sizerStatus = new wxBoxSizer( wxHORIZONTAL );
m_status = new wxTextCtrl( this, wxID_ANY, wxT("No hit"), wxDefaultPosition, wxDefaultSize, 0|wxBORDER_NONE );
m_status->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ) );
m_status->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWFRAME ) );
sizerStatus->Add( m_status, 0, wxALL|wxEXPAND, 5 );
m_status = new wxStaticText( this, wxID_ANY, wxT("Status"), wxDefaultPosition, wxDefaultSize, 0 );
m_status->Wrap( -1 );
sizerStatus->Add( m_status, 0, wxALL, 5 );
m_cancel = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_cancel->Hide();

View File

@ -14,7 +14,6 @@
<property name="file">dialog_find_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">0</property>
<property name="name">MyProject2</property>
@ -26,20 +25,19 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg">wxSYS_COLOUR_ACTIVEBORDER</property>
<property name="bg">wxSYS_COLOUR_WINDOW</property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg">wxSYS_COLOUR_APPWORKSPACE</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
@ -115,7 +113,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -164,7 +162,7 @@
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg">wxSYS_COLOUR_APPWORKSPACE</property>
<property name="bg">wxSYS_COLOUR_WINDOW</property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
@ -177,7 +175,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -254,7 +252,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -318,7 +316,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -382,7 +380,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -446,7 +444,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -521,7 +519,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -585,7 +583,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -649,7 +647,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -713,7 +711,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -777,7 +775,7 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
@ -840,7 +838,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -914,7 +911,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -988,7 +984,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1062,11 +1057,11 @@
<property name="name">sizerStatus</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -1076,7 +1071,7 @@
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg">wxSYS_COLOUR_WINDOWFRAME</property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
@ -1088,16 +1083,17 @@
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg">wxSYS_COLOUR_WINDOWTEXT</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Status</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
@ -1116,14 +1112,10 @@
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value">No hit</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxBORDER_NONE</property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -1139,7 +1131,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.9.0 Nov 22 2019)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -19,11 +19,10 @@
#include <wx/combobox.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/gauge.h>
#include <wx/frame.h>
@ -52,7 +51,7 @@ class DIALOG_FIND_BASE : public DIALOG_SHIM
wxButton* m_findNext;
wxButton* m_findPrevious;
wxButton* m_searchAgain;
wxTextCtrl* m_status;
wxStaticText* m_status;
wxButton* m_cancel;
wxGauge* m_gauge;