KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/widgets/search_handlers.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef SEARCH_HANDLERS_H
25#define SEARCH_HANDLERS_H
26
27#include <functional>
28#include <widgets/search_pane.h>
29
30class SCH_ITEM;
31class SCH_EDIT_FRAME;
32
34{
37};
38
40{
41public:
42 SCH_SEARCH_HANDLER( const wxString& aName, SCH_EDIT_FRAME* aFrame ) :
43 SEARCH_HANDLER( aName ),
44 m_frame( aFrame )
45 {}
46
47 void ActivateItem( long aItemRow ) override;
48
49 wxString GetResultCell( int aRow, int aCol ) override
50 {
51 if( aRow >= static_cast<int>( m_hitlist.size() ) )
52 return wxEmptyString;
53
54 const SCH_SEARCH_HIT& hit = m_hitlist[aRow];
55
56 if( !hit.item )
57 return wxEmptyString;
58
59 return getResultCell( hit, aCol );
60 }
61
62 void FindAll( const std::function<bool( SCH_ITEM*, SCH_SHEET_PATH* )>& aCollector );
63 void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) override;
64 void SelectItems( std::vector<long>& aItemRows ) override;
65
66protected:
67 virtual wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) = 0;
68
69protected:
71 std::vector<SCH_SEARCH_HIT> m_hitlist;
72};
73
75{
76public:
78
79 int Search( const wxString& aQuery ) override;
80
81protected:
82 wxString getResultCell( const SCH_SEARCH_HIT& aHit, int aCol ) override;
83};
84
86{
87public:
89
90 int Search( const wxString& aQuery ) override;
91
92protected:
93 wxString getResultCell( const SCH_SEARCH_HIT& aHit, int aCol ) override;
94};
95
97{
98public:
100
101 int Search( const wxString& aQuery ) override;
102
103protected:
104 wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) override;
105};
106
108{
109public:
111
112 int Search( const wxString& aQuery ) override;
113
114protected:
115 wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) override;
116};
117
118#endif
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &aHit, int aCol) override
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol)=0
std::vector< SCH_SEARCH_HIT > m_hitlist
void SelectItems(std::vector< long > &aItemRows) override
void FindAll(const std::function< bool(SCH_ITEM *, SCH_SHEET_PATH *)> &aCollector)
void Sort(int aCol, bool aAscending, std::vector< long > *aSelection) override
void ActivateItem(long aItemRow) override
wxString GetResultCell(int aRow, int aCol) override
SCH_SEARCH_HANDLER(const wxString &aName, SCH_EDIT_FRAME *aFrame)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString getResultCell(const SCH_SEARCH_HIT &aHit, int aCol) override
int Search(const wxString &aQuery) override
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override