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
22#include <functional>
24#include <widgets/wx_grid.h>
25
26class DIALOG_SHIM;
29
44
50{
52
53public:
54 LIB_TABLE_GRID_DATA_MODEL( DIALOG_SHIM* aParent, WX_GRID* aGrid, const LIBRARY_TABLE& aTableToEdit,
55 LIBRARY_MANAGER_ADAPTER* aAdapter, const wxArrayString& aPluginChoices,
56 wxString* aMRUDirectory, const wxString& aProjectPath );
57
59
60 //-----<wxGridTableBase overloads>-------------------------------------------
61
62 int GetNumberRows() override { return (int) size(); }
63 int GetNumberCols() override { return COL_COUNT; }
64
65 wxString GetValue( int aRow, int aCol ) override;
66 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
67
68 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
69
70 bool GetValueAsBool( int aRow, int aCol ) override;
71
72 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
73
74 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
75
76 bool IsEmptyCell( int aRow, int aCol ) override
77 {
78 return !GetValue( aRow, aCol );
79 }
80
81 bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) override;
82
83 bool AppendRows( size_t aNumRows = 1 ) override;
84
85 bool DeleteRows( size_t aPos, size_t aNumRows ) override;
86
87 wxString GetColLabelValue( int aCol ) override;
88
89 bool ContainsNickname( const wxString& aNickname );
90
91 LIBRARY_TABLE_ROW& At( size_t aIndex )
92 {
93 return at( aIndex );
94 }
95
97
99
100 void RecheckRows();
101
102 void SetChangeCallback( std::function<void()> aCallback ) { m_changeCallback = std::move( aCallback ); }
103
104protected:
105 bool badCoords( int aRow, int aCol );
106
107 virtual wxString getFileTypes( WX_GRID* aGrid, int aRow ) = 0;
108
109 virtual LIBRARY_TABLE_ROW& at( size_t aIndex );
110
111 virtual size_t size() const;
112
114
116
118
119 virtual void push_back( const LIBRARY_TABLE_ROW& aRow );
120
122
123protected:
126
127 std::function<void()> m_changeCallback;
128
129 wxGridCellAttr* m_uriEditor;
130 wxGridCellAttr* m_typesEditor;
131 wxGridCellAttr* m_boolAttr;
132 wxGridCellAttr* m_warningAttr;
133 wxGridCellAttr* m_noStatusAttr;
134 wxGridCellAttr* m_editSettingsAttr;
135 wxGridCellAttr* m_openTableAttr;
136
139};
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
void SetChangeCallback(std::function< void()> aCallback)
wxString GetColLabelValue(int aCol) override
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
std::function< void()> m_changeCallback
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::deque< LIBRARY_TABLE_ROW >::iterator LIBRARY_TABLE_ROWS_ITER