Only search the current tab on events

This commit is contained in:
Marek Roszko 2022-09-20 23:38:06 -04:00
parent 1b962a1660
commit 30dbcbbcf5
5 changed files with 42 additions and 5 deletions

View File

@ -59,10 +59,19 @@ void SEARCH_PANE::AddSearcher( SEARCH_HANDLER* aHandler )
void SEARCH_PANE::RefreshSearch()
{
SEARCH_PANE_TAB* tab = GetCurrentTab();
if( tab )
tab->Search( m_lastQuery );
}
void SEARCH_PANE::ClearAllResults()
{
for( SEARCH_PANE_TAB* tab : m_tabs )
{
tab->Search( m_lastQuery );
tab->Clear();
}
}
@ -80,3 +89,18 @@ void SEARCH_PANE::FocusSearch()
{
m_searchCtrl1->SetFocus();
}
void SEARCH_PANE::OnNotebookPageChanged( wxBookCtrlEvent& aEvent )
{
SEARCH_PANE_TAB* tab = GetCurrentTab();
if( tab )
tab->Search( m_lastQuery );
}
SEARCH_PANE_TAB* SEARCH_PANE::GetCurrentTab() const
{
return dynamic_cast<SEARCH_PANE_TAB*>( m_notebook->GetCurrentPage() );
}

View File

@ -31,11 +31,11 @@ SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* p
RefreshColumnNames();
Bind( wxEVT_LIST_ITEM_SELECTED, &SEARCH_PANE_LISTVIEW::onItemSelected, this );
Bind( wxEVT_LIST_ITEM_SELECTED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this );
}
void SEARCH_PANE_LISTVIEW::onItemSelected( wxListEvent& aEvent )
void SEARCH_PANE_LISTVIEW::OnItemSelected( wxListEvent& aEvent )
{
long idx = aEvent.GetIndex();
@ -89,6 +89,13 @@ void SEARCH_PANE_TAB::Search( wxString& query )
}
void SEARCH_PANE_TAB::Clear()
{
m_listView->SetItemCount( 0 );
m_listView->Refresh();
}
void SEARCH_PANE_TAB::RefreshColumnNames()
{
m_listView->RefreshColumnNames();

View File

@ -54,13 +54,17 @@ public:
void AddSearcher( SEARCH_HANDLER* aHandler );
void OnSearchTextEntry( wxCommandEvent& aEvent ) override;
void OnNotebookPageChanged( wxBookCtrlEvent& aEvent ) override;
void RefreshSearch();
void OnLanguageChange();
void FocusSearch();
void ClearAllResults();
protected:
SEARCH_PANE_TAB* GetCurrentTab() const;
private:
EDA_DRAW_FRAME* m_frame;
std::vector<SEARCH_HANDLER*> m_handlers;
std::vector<SEARCH_PANE_TAB*> m_tabs;

View File

@ -39,7 +39,7 @@ public:
protected:
wxString OnGetItemText( long item, long column ) const override;
void onItemSelected( wxListEvent& aEvent );
void OnItemSelected( wxListEvent& aEvent );
private:
SEARCH_HANDLER* m_handler;
@ -54,6 +54,7 @@ public:
const wxSize& aSize = wxDefaultSize );
void Search( wxString& query );
void Clear();
void RefreshColumnNames();
SEARCH_HANDLER* GetSearchHandler() const { return m_handler; }

View File

@ -67,6 +67,7 @@ void PCB_SEARCH_PANE::onBoardChanged( wxCommandEvent& event )
if( m_brd != nullptr )
m_brd->AddListener( this );
ClearAllResults();
RefreshSearch();
event.Skip();