KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_table_grid_data_model.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 modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23#include <widgets/wx_grid.h>
24
25class DIALOG_SHIM;
28
43
49{
51
52public:
53 LIB_TABLE_GRID_DATA_MODEL( DIALOG_SHIM* aParent, WX_GRID* aGrid, const LIBRARY_TABLE& aTableToEdit,
54 LIBRARY_MANAGER_ADAPTER* aAdapter, const wxArrayString& aPluginChoices,
55 wxString* aMRUDirectory, const wxString& aProjectPath );
56
58
59 //-----<wxGridTableBase overloads>-------------------------------------------
60
61 int GetNumberRows() override { return (int) size(); }
62 int GetNumberCols() override { return COL_COUNT; }
63
64 wxString GetValue( int aRow, int aCol ) override;
65 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
66
67 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
68
69 bool GetValueAsBool( int aRow, int aCol ) override;
70
71 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
72
73 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
74
75 bool IsEmptyCell( int aRow, int aCol ) override
76 {
77 return !GetValue( aRow, aCol );
78 }
79
80 bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) override;
81
82 bool AppendRows( size_t aNumRows = 1 ) override;
83
84 bool DeleteRows( size_t aPos, size_t aNumRows ) override;
85
86 wxString GetColLabelValue( int aCol ) override;
87
88 bool ContainsNickname( const wxString& aNickname );
89
90 LIBRARY_TABLE_ROW& At( size_t aIndex )
91 {
92 return at( aIndex );
93 }
94
96
98
99protected:
100 virtual wxString getFileTypes( WX_GRID* aGrid, int aRow ) = 0;
101
102 virtual LIBRARY_TABLE_ROW& at( size_t aIndex );
103
104 virtual size_t size() const;
105
107
109
111
112 virtual void push_back( const LIBRARY_TABLE_ROW& aRow );
113
115
116protected:
119
120 wxGridCellAttr* m_uriEditor;
121 wxGridCellAttr* m_typesEditor;
122 wxGridCellAttr* m_boolAttr;
123 wxGridCellAttr* m_warningAttr;
124 wxGridCellAttr* m_editSettingsAttr;
125 wxGridCellAttr* m_openTableAttr;
126
129};
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:68
The interface used by the classes that actually can load IO plugins for the different parts of KiCad ...
virtual LIBRARY_TABLE_ROWS_ITER begin()
bool AppendRows(size_t aNumRows=1) override
virtual LIBRARY_TABLE_ROW & at(size_t aIndex)
LIBRARY_MANAGER_ADAPTER * Adapter() const
bool ContainsNickname(const wxString &aNickname)
virtual LIBRARY_TABLE_ROWS_ITER erase(LIBRARY_TABLE_ROWS_ITER aFirst, LIBRARY_TABLE_ROWS_ITER aLast)
void SetValueAsBool(int aRow, int aCol, bool aValue) override
virtual LIBRARY_TABLE_ROWS_ITER insert(LIBRARY_TABLE_ROWS_ITER aIterator, const LIBRARY_TABLE_ROW &aRow)
wxString GetValue(int aRow, int aCol) override
wxString GetColLabelValue(int aCol) override
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
bool GetValueAsBool(int aRow, int aCol) override
bool DeleteRows(size_t aPos, size_t aNumRows) override
virtual void push_back(const LIBRARY_TABLE_ROW &aRow)
bool InsertRows(size_t aPos=0, size_t aNumRows=1) override
LIBRARY_MANAGER_ADAPTER * m_adapter
Handle to the adapter for the type of table this grid represents (may be null)
LIBRARY_TABLE_ROW & At(size_t aIndex)
void SetValue(int aRow, int aCol, const wxString &aValue) override
LIBRARY_TABLE m_table
Working copy of a table.
virtual wxString getFileTypes(WX_GRID *aGrid, int aRow)=0
bool IsEmptyCell(int aRow, int aCol) override
LIB_TABLE_GRID_DATA_MODEL(DIALOG_SHIM *aParent, WX_GRID *aGrid, const LIBRARY_TABLE &aTableToEdit, LIBRARY_MANAGER_ADAPTER *aAdapter, const wxArrayString &aPluginChoices, wxString *aMRUDirectory, const wxString &aProjectPath)
virtual LIBRARY_TABLE_ROW makeNewRow()
std::vector< LIBRARY_TABLE_ROW >::iterator LIBRARY_TABLE_ROWS_ITER