KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew/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, 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 <widgets/search_pane.h>
28#include <board_statistics.h>
29#include <unordered_map>
30
31class PCB_EDIT_FRAME;
32
33
35{
36public:
37 PCB_SEARCH_HANDLER( const wxString& aName, PCB_EDIT_FRAME* aFrame ) :
38 SEARCH_HANDLER( aName ),
39 m_frame( aFrame )
40 {}
41
42 wxString GetResultCell( int aRow, int aCol ) override
43 {
44 if( m_frame->IsClosing() )
45 return wxEmptyString;
46
47 if( aRow >= static_cast<int>(m_hitlist.size() ) )
48 return wxEmptyString;
49
50 BOARD_ITEM* item = m_hitlist[aRow];
51
52 if( !item )
53 return wxEmptyString;
54
55 return getResultCell( item, aCol );
56 }
57
58 void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) override;
59
60 void SelectItems( std::vector<long>& aItemRows ) override;
61 void ActivateItem( long aItemRow ) override;
62
63protected:
64 virtual wxString getResultCell( BOARD_ITEM* aItem, int aCol ) = 0;
65
66protected:
68 std::vector<BOARD_ITEM*> m_hitlist;
69};
70
71
73{
74public:
76
77 int Search( const wxString& aQuery ) override;
78
79private:
80 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
81};
82
83
85{
86public:
88
89 int Search( const wxString& aQuery ) override;
90
91private:
92 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
93};
94
95
97{
98public:
100
101 int Search( const wxString& aQuery ) override;
102
103private:
104 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
105};
106
107
109{
110public:
112
113 int Search( const wxString& aQuery ) override;
114
115private:
116 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
117};
118
119
121{
122public:
124
125 int Search( const wxString& aQuery ) override;
126 void SelectItems( std::vector<long>& aItemRows ) override;
127 void ActivateItem( long aItemRow ) override;
128
129private:
130 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
131};
132
133
135{
136public:
138
139 int Search( const wxString& aQuery ) override;
140 void SelectItems( std::vector<long>& aItemRows ) override;
141 void ActivateItem( long aItemRow ) override;
142
143private:
144 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
145};
146
147
149{
150public:
152
153 int Search( const wxString& aQuery ) override;
154 void Sort( int aCol, bool aAscending, std::vector<long>* aSelection ) override;
155 void SelectItems( std::vector<long>& aItemRows ) override;
156
157private:
158 wxString getResultCell( BOARD_ITEM* aItem, int aCol ) override;
159
160 wxString cellText( const DRILL_LINE_ITEM& e, int col ) const;
161 bool rowMatchesQuery( const DRILL_LINE_ITEM& e, const wxString& aQuery ) const;
162
163private:
165 {
167 // While a DRILL_ROW will usually represent multiple identical drills/BOARD_ITEMs,
168 // keeping a pointer to one BOARD_ITEM allows use to provide
169 // compatibility with the rest of PCB_SEARCH_HANDLER, and also to allow
170 // some convenience actions to work when there is just a single entry, e.g.
171 // activating the item to show its properties.
173 };
174
175 std::vector<DRILL_ROW> m_drills;
176
177 // This maps the DRILL_ROW.item to the index in m_drills to allow fast lookup
178 std::unordered_map<BOARD_ITEM*, int> m_ptrToDrill;
179
181};
182
183#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:79
wxString cellText(const DRILL_LINE_ITEM &e, int col) const
std::unordered_map< BOARD_ITEM *, int > m_ptrToDrill
void SelectItems(std::vector< long > &aItemRows) override
int Search(const wxString &aQuery) override
bool rowMatchesQuery(const DRILL_LINE_ITEM &e, const wxString &aQuery) const
DRILL_SEARCH_HANDLER(PCB_EDIT_FRAME *aFrame)
void Sort(int aCol, bool aAscending, std::vector< long > *aSelection) override
std::vector< DRILL_ROW > m_drills
wxString getResultCell(BOARD_ITEM *aItem, int aCol) override
FOOTPRINT_SEARCH_HANDLER(PCB_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
wxString getResultCell(BOARD_ITEM *aItem, int aCol) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override
int Search(const wxString &aQuery) override
GROUP_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
void ActivateItem(long aItemRow) override
int Search(const wxString &aQuery) override
NETS_SEARCH_HANDLER(PCB_EDIT_FRAME *aFrame)
wxString getResultCell(BOARD_ITEM *aItem, int aCol) override
void SelectItems(std::vector< long > &aItemRows) override
The main frame for Pcbnew.
void ActivateItem(long aItemRow) override
PCB_SEARCH_HANDLER(const wxString &aName, PCB_EDIT_FRAME *aFrame)
wxString GetResultCell(int aRow, int aCol) override
void Sort(int aCol, bool aAscending, std::vector< long > *aSelection) override
void SelectItems(std::vector< long > &aItemRows) override
std::vector< BOARD_ITEM * > m_hitlist
virtual wxString getResultCell(BOARD_ITEM *aItem, int aCol)=0
wxString getResultCell(BOARD_ITEM *aItem, int aCol) override
RATSNEST_SEARCH_HANDLER(PCB_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
void SelectItems(std::vector< long > &aItemRows) override
void ActivateItem(long aItemRow) override
SEARCH_HANDLER(const wxString &aName)
Definition search_pane.h:38
TEXT_SEARCH_HANDLER(SCH_EDIT_FRAME *aFrame)
int Search(const wxString &aQuery) override
wxString getResultCell(const SCH_SEARCH_HIT &hit, int aCol) override
ZONE_SEARCH_HANDLER(PCB_EDIT_FRAME *aFrame)
wxString getResultCell(BOARD_ITEM *aItem, int aCol) override
int Search(const wxString &aQuery) override