2022-09-14 02:59:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <widgets/search_pane.h>
|
|
|
|
#include <widgets/search_pane_tab.h>
|
|
|
|
#include <eda_draw_frame.h>
|
|
|
|
#include <kiway.h>
|
|
|
|
|
|
|
|
|
|
|
|
SEARCH_PANE::SEARCH_PANE( EDA_DRAW_FRAME* aFrame ) :
|
|
|
|
SEARCH_PANE_BASE( aFrame ),
|
|
|
|
m_frame( aFrame )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SEARCH_PANE::~SEARCH_PANE()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::OnLanguageChange()
|
|
|
|
{
|
|
|
|
for( size_t i = 0; i < m_notebook->GetPageCount(); ++i )
|
|
|
|
{
|
|
|
|
wxWindow* page = m_notebook->GetPage( i );
|
|
|
|
SEARCH_PANE_TAB* tab = dynamic_cast<SEARCH_PANE_TAB*>( page );
|
|
|
|
|
|
|
|
tab->RefreshColumnNames();
|
2022-12-10 23:37:23 +00:00
|
|
|
m_notebook->SetPageText( i, wxGetTranslation( tab->GetSearchHandler()->GetName() ) );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::AddSearcher( SEARCH_HANDLER* aHandler )
|
|
|
|
{
|
|
|
|
SEARCH_PANE_TAB* tab = new SEARCH_PANE_TAB( aHandler, m_notebook );
|
|
|
|
|
2022-12-10 23:37:23 +00:00
|
|
|
m_notebook->AddPage( tab, wxGetTranslation( aHandler->GetName() ) );
|
2022-09-14 02:59:57 +00:00
|
|
|
m_handlers.push_back( aHandler );
|
|
|
|
m_tabs.push_back( tab );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::RefreshSearch()
|
2022-09-21 03:38:06 +00:00
|
|
|
{
|
|
|
|
SEARCH_PANE_TAB* tab = GetCurrentTab();
|
|
|
|
|
|
|
|
if( tab )
|
|
|
|
tab->Search( m_lastQuery );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::ClearAllResults()
|
2022-09-14 02:59:57 +00:00
|
|
|
{
|
|
|
|
for( SEARCH_PANE_TAB* tab : m_tabs )
|
|
|
|
{
|
2022-09-21 03:38:06 +00:00
|
|
|
tab->Clear();
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::OnSearchTextEntry( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxString query = m_searchCtrl1->GetValue();
|
|
|
|
m_lastQuery = query;
|
|
|
|
|
|
|
|
RefreshSearch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SEARCH_PANE::FocusSearch()
|
|
|
|
{
|
|
|
|
m_searchCtrl1->SetFocus();
|
2022-09-21 03:38:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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() );
|
2022-09-14 02:59:57 +00:00
|
|
|
}
|