From 9806d846b2e83b87a7d61917902628c7fe3fa9f4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 9 Jul 2020 14:21:28 +0100 Subject: [PATCH] Remove redundant Text Filter toggle icon and fix . (Enter in the filter textbox should execute the search, not close the dialog.) Fixes https://gitlab.com/kicad/code/kicad/issues/4768 --- cvpcb/cvpcb_mainframe.cpp | 32 +++++++++++++++++--------------- cvpcb/cvpcb_mainframe.h | 1 - cvpcb/footprints_listbox.cpp | 2 +- cvpcb/listboxes.h | 3 +-- cvpcb/toolbars_cvpcb.cpp | 9 ++++----- cvpcb/tools/cvpcb_actions.cpp | 6 ------ cvpcb/tools/cvpcb_actions.h | 1 - cvpcb/tools/cvpcb_control.cpp | 1 - 8 files changed, 23 insertions(+), 32 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 4966a369dd..f62b259acc 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -330,11 +330,6 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent ) // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list // of available footprints which match the filter - m_currentSearchPattern = m_tcFilterString->GetValue(); - - if(( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN ) == 0 ) - return; - wxListEvent l_event; OnSelectComponent( l_event ); } @@ -350,7 +345,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) libraryName = m_libListBox->GetSelectedLibrary(); m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component, - m_currentSearchPattern, m_filteringOptions); + m_tcFilterString->GetValue(), m_filteringOptions ); if( component && component->GetFPID().IsValid() ) m_footprintListBox->SetSelectedFootprint( component->GetFPID() ); @@ -541,10 +536,6 @@ void CVPCB_MAINFRAME::SetFootprintFilter( FOOTPRINTS_LISTBOX::FP_FILTER_T aFilte { int option = aFilter; - // Extract the current search patten when needed - if( option == FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN ) - m_currentSearchPattern = m_tcFilterString->GetValue(); - // Apply the filter accordingly switch( aAction ) { @@ -589,7 +580,10 @@ void CVPCB_MAINFRAME::DisplayStatus() } } - filters += _( "key words" ) + wxString::Format( wxT( " (%s)" ), msg ); + filters += _( "key words" ); + + if( !msg.IsEmpty() ) + filters += wxString::Format( wxT( " (%s)" ), msg ); } if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) ) @@ -602,7 +596,10 @@ void CVPCB_MAINFRAME::DisplayStatus() if( !filters.IsEmpty() ) filters += wxT( ", " ); - filters += _( "pin count" ) + wxString::Format( wxT( " (%s)" ), msg ); + filters += _( "pin count" ); + + if( !msg.IsEmpty() ) + filters += wxString::Format( wxT( " (%s)" ), msg ); } if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) ) @@ -612,15 +609,20 @@ void CVPCB_MAINFRAME::DisplayStatus() if( !filters.IsEmpty() ) filters += wxT( ", " ); - filters += _( "library" ) + wxString::Format( wxT( " (%s)" ), msg ); + filters += _( "library" ); + + if( !msg.IsEmpty() ) + filters += wxString::Format( wxT( " (%s)" ), msg ); } - if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN ) ) + wxString textFilter = m_tcFilterString->GetValue(); + + if( !textFilter.IsEmpty() ) { if( !filters.IsEmpty() ) filters += wxT( ", " ); - filters += _( "search text" ); + filters += _( "search text" ) + wxString::Format( wxT( " (%s)" ), textFilter ); } if( filters.IsEmpty() ) diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index a4cf0b3d26..0841334763 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -61,7 +61,6 @@ class CVPCB_MAINFRAME : public KIWAY_PLAYER { friend struct CV::IFACE; - wxString m_currentSearchPattern; NETLIST m_netlist; int m_filteringOptions; ACTION_TOOLBAR* m_mainToolBar; diff --git a/cvpcb/footprints_listbox.cpp b/cvpcb/footprints_listbox.cpp index 451509b58b..df13242bc4 100644 --- a/cvpcb/footprints_listbox.cpp +++ b/cvpcb/footprints_listbox.cpp @@ -149,7 +149,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a if( aFilterType & FILTERING_BY_LIBRARY ) filter.FilterByLibrary( aLibName ); - if( aFilterType & FILTERING_BY_TEXT_PATTERN ) + if( !aFootPrintFilterPattern.IsEmpty() ) filter.FilterByTextPattern( aFootPrintFilterPattern ); if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() ) diff --git a/cvpcb/listboxes.h b/cvpcb/listboxes.h index fee85be4eb..ec3ddd6e3e 100644 --- a/cvpcb/listboxes.h +++ b/cvpcb/listboxes.h @@ -96,8 +96,7 @@ public: UNFILTERED_FP_LIST = 0, FILTERING_BY_COMPONENT_FP_FILTERS = 0x0001, FILTERING_BY_PIN_COUNT = 0x0002, - FILTERING_BY_LIBRARY = 0x0004, - FILTERING_BY_TEXT_PATTERN = 0x0008 + FILTERING_BY_LIBRARY = 0x0004 }; FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ); diff --git a/cvpcb/toolbars_cvpcb.cpp b/cvpcb/toolbars_cvpcb.cpp index c3318bf48c..d70579f81e 100644 --- a/cvpcb/toolbars_cvpcb.cpp +++ b/cvpcb/toolbars_cvpcb.cpp @@ -79,13 +79,14 @@ void CVPCB_MAINFRAME::ReCreateHToolbar() m_mainToolBar->Add( CVPCB_ACTIONS::FilterFPbyLibrary, true ); m_mainToolBar->AddScaledSeparator( this ); - m_mainToolBar->Add( CVPCB_ACTIONS::FilterFPbyTextPattern, true ); - m_tcFilterString = new wxTextCtrl( m_mainToolBar, ID_CVPCB_FILTER_TEXT_EDIT ); + m_tcFilterString = new wxTextCtrl( m_mainToolBar, ID_CVPCB_FILTER_TEXT_EDIT, wxEmptyString, + wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + + m_tcFilterString->Bind( wxEVT_TEXT_ENTER, &CVPCB_MAINFRAME::OnEnterFilteringText, this ); m_mainToolBar->AddControl( m_tcFilterString ); - // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); } @@ -105,7 +106,5 @@ void CVPCB_MAINFRAME::SyncToolbars() filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) ); m_mainToolBar->Toggle( CVPCB_ACTIONS::filterFPbyPin, filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) ); - m_mainToolBar->Toggle( CVPCB_ACTIONS::FilterFPbyTextPattern, - filterActive( FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN ) ); m_mainToolBar->Refresh(); } diff --git a/cvpcb/tools/cvpcb_actions.cpp b/cvpcb/tools/cvpcb_actions.cpp index 531a5a9289..58f5884ddb 100644 --- a/cvpcb/tools/cvpcb_actions.cpp +++ b/cvpcb/tools/cvpcb_actions.cpp @@ -152,9 +152,3 @@ TOOL_ACTION CVPCB_ACTIONS::FilterFPbyLibrary( "cvpcb.Control.FilterFPbyLibrary", module_library_list_xpm, AF_NONE, (void*) FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ); -TOOL_ACTION CVPCB_ACTIONS::FilterFPbyTextPattern( "cvpcb.Control.FilterFPbyTextPattern", - AS_GLOBAL, 0, "", - _( "Filter by display name" ), - _( "Filter footprint list using plain text matching or regular expressions" ), - module_name_filtered_list_xpm, AF_NONE, - (void*) FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN ); diff --git a/cvpcb/tools/cvpcb_actions.h b/cvpcb/tools/cvpcb_actions.h index a8fb63baa2..3f59335f95 100644 --- a/cvpcb/tools/cvpcb_actions.h +++ b/cvpcb/tools/cvpcb_actions.h @@ -69,7 +69,6 @@ public: static TOOL_ACTION FilterFPbyFPFilters; static TOOL_ACTION filterFPbyPin; static TOOL_ACTION FilterFPbyLibrary; - static TOOL_ACTION FilterFPbyTextPattern; ///> @copydoc COMMON_ACTIONS::TranslateLegacyId() virtual OPT TranslateLegacyId( int aId ) override { return OPT(); } diff --git a/cvpcb/tools/cvpcb_control.cpp b/cvpcb/tools/cvpcb_control.cpp index 6eb1e09fb4..1ec4e4028c 100644 --- a/cvpcb/tools/cvpcb_control.cpp +++ b/cvpcb/tools/cvpcb_control.cpp @@ -319,5 +319,4 @@ void CVPCB_CONTROL::setTransitions() Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::FilterFPbyFPFilters.MakeEvent() ); Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::FilterFPbyLibrary.MakeEvent() ); Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::filterFPbyPin.MakeEvent() ); - Go( &CVPCB_CONTROL::ToggleFootprintFilter, CVPCB_ACTIONS::FilterFPbyTextPattern.MakeEvent() ); }