KiCad PCB EDA Suite
cleanup_item.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) 2020 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 CLEANUP_ITEM_H
25 #define CLEANUP_ITEM_H
26 
27 #include <rc_item.h>
28 #include <drc/drc.h>
29 
30 class PCB_BASE_FRAME;
31 
32 
46 };
47 
48 class CLEANUP_ITEM : public RC_ITEM
49 {
50 public:
51  CLEANUP_ITEM( int aErrorCode );
52 
57  wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
58 
64  wxString ShowHtml( PCB_BASE_FRAME* aFrame ) const;
65 };
66 
67 
75 {
76  std::vector<CLEANUP_ITEM*>* m_sourceVector; // owns its CLEANUP_ITEMs
77 
78 public:
79 
80  VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<CLEANUP_ITEM*>* aList ) :
81  m_sourceVector( aList )
82  {
83  }
84 
85  void SetSeverities( int aSeverities ) override
86  {
87  }
88 
89  int GetCount( int aSeverity = -1 ) override
90  {
91  return m_sourceVector->size();
92  }
93 
94  CLEANUP_ITEM* GetItem( int aIndex ) override
95  {
96  return m_sourceVector->at( aIndex );
97  }
98 
99  void DeleteItem( int aIndex, bool aDeep ) override
100  {
101  if( aDeep )
102  {
103  CLEANUP_ITEM* item = m_sourceVector->at( aIndex );
104  delete item;
105 
106  m_sourceVector->erase( m_sourceVector->begin() + aIndex );
107  }
108  }
109 
110  void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override
111  {
112  if( aDeep )
113  {
114  for( CLEANUP_ITEM* item : *m_sourceVector )
115  delete item;
116 
117  m_sourceVector->clear();
118  }
119  }
120 };
121 
122 
123 
124 #endif // CLEANUP_ITEM_H
CLEANUP_ITEM(int aErrorCode)
wxString ShowHtml(PCB_BASE_FRAME *aFrame) const
Function ShowHtml translates this object into a fragment of HTML suitable for the wxHtmlListBox class...
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:73
int GetCount(int aSeverity=-1) override
Definition: cleanup_item.h:89
void DeleteAllItems(bool aIncludeExclusions, bool aDeep) override
Definition: cleanup_item.h:110
void DeleteItem(int aIndex, bool aDeep) override
Function DeleteItem removes (and optionally deletes) the indexed item from the list.
Definition: cleanup_item.h:99
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:42
wxString GetErrorText() const
Definition: rc_item.h:165
std::vector< CLEANUP_ITEM * > * m_sourceVector
Definition: cleanup_item.h:76
VECTOR_CLEANUP_ITEMS_PROVIDER(std::vector< CLEANUP_ITEM * > *aList)
Definition: cleanup_item.h:80
VECTOR_CLEANUP_ITEMS_PROVIDER is an implementation of the interface named RC_ITEMS_PROVIDER which use...
Definition: cleanup_item.h:74
void SetSeverities(int aSeverities) override
Definition: cleanup_item.h:85
CLEANUP_ITEM * GetItem(int aIndex) override
Function GetItem retrieves a RC_ITEM by index.
Definition: cleanup_item.h:94
CLEANUP_RC_CODE
Definition: cleanup_item.h:33
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.