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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SEARCH_HANDLERS_H
21#define SEARCH_HANDLERS_H
22
23#include <functional>
24#include <widgets/search_pane.h>
25
26class SCH_ITEM;
27class SCH_EDIT_FRAME;
28
34
36{
37public:
38 SCH_SEARCH_HANDLER( const wxString& aName, SCH_EDIT_FRAME* aFrame ) :
39 SEARCH_HANDLER( aName ),
40 m_frame( aFrame )
41 {}
42
44 {
45 m_resultsValid = false;
46 m_hitlist.clear();
47 }
48
49 void ActivateItem( long aItemRow ) override;
50
51 wxString GetResultCell( int aRow, int aCol ) override
52 {
53 if( !m_resultsValid || m_frame->IsClosing() )
54 return wxEmptyString;
55
56 if( aRow >= static_cast<int>( m_hitlist.size() ) )
57 return wxEmptyString;
58
59 const SCH_SEARCH_HIT& hit = m_hitlist[aRow];
60
61 if( !hit.item )
62 return wxEmptyString;
63
64 return getResultCell( hit, aCol );
65 }
66
67 void FindAll( const std::function<bool( SCH_ITEM*, SCH_SHEET_PATH* )>& aCollector );
68 void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) override;
69 void SelectItems( std::vector<long>& aItemRows ) override;
70
71protected:
72 virtual wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) = 0;
73
74protected:
76 std::vector<SCH_SEARCH_HIT> m_hitlist;
77 bool m_resultsValid = false;
78};
79
81{
82public:
84
85 int Search( const wxString& aQuery ) override;
86
87protected:
88 wxString getResultCell( const SCH_SEARCH_HIT& aHit, int aCol ) override;
89};
90
92{
93public:
95
96 int Search( const wxString& aQuery ) override;
97
98protected:
99 wxString getResultCell( const SCH_SEARCH_HIT& aHit, int aCol ) override;
100};
101
103{
104public:
106
107 int Search( const wxString& aQuery ) override;
108
109protected:
110 wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) override;
111};
112
114{
115public:
117
118 int Search( const wxString& aQuery ) override;
119
120protected:
121 wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) override;
122};
123
125{
126public:
128
129 int Search( const wxString& aQuery ) override;
130
131protected:
132 wxString getResultCell( const SCH_SEARCH_HIT& hit, int aCol ) override;
133};
134
135#endif
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override
int Search(const wxString &aQuery) override
GROUP_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
LABEL_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override
int Search(const wxString &aQuery) override
POWER_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
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:165
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...
SEARCH_HANDLER(const wxString &aName)
Definition search_pane.h:38
wxString getResultCell(const SCH_SEARCH_HIT &aHit, int aCol) override
SYMBOL_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
TEXT_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override