KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fields_view_controls_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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <widgets/wx_grid.h>
24
25// Columns for the View Fields grid
26#define DISPLAY_NAME_COLUMN 0 // The field name in the data model (translated)
27#define LABEL_COLUMN 1 // The field name's label for exporting (CSV, etc.)
28#define SHOW_FIELD_COLUMN 2
29#define GROUP_BY_COLUMN 3
30#define VIEW_FIELDS_COL_COUNT 4
31
32
33// Data model for the list of fields to view (and to group-by) for the Symbol Fields Table
35{
36public:
38 m_forBOM( aForBOM )
39 {}
40
41 ~VIEW_CONTROLS_GRID_DATA_MODEL() override = default;
42
43 int GetNumberRows() override { return (int) m_fields.size(); }
44 int GetNumberCols() override { return VIEW_FIELDS_COL_COUNT; }
45
46 wxString GetColLabelValue( int aCol ) override;
47
48 bool IsEmptyCell( int aRow, int aCol ) override
49 {
50 return false; // don't allow adjacent cell overflow, even if we are actually empty
51 }
52
53 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
54 {
55 switch( aCol )
56 {
58 case LABEL_COLUMN: return aTypeName == wxGRID_VALUE_STRING;
59
61 case GROUP_BY_COLUMN: return aTypeName == wxGRID_VALUE_BOOL;
62
63 default: wxFAIL; return false;
64 }
65 }
66
67 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
68 {
69 return CanGetValueAs( aRow, aCol, aTypeName );
70 }
71
72 wxString GetValue( int aRow, int aCol ) override;
73 bool GetValueAsBool( int aRow, int aCol ) override;
74
75 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
76 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
77
78 void AppendRow( const wxString& aFieldName, const wxString& aBOMName, bool aShow, bool aGroupBy );
79 void DeleteRow( int aRow );
80
81 wxString GetCanonicalFieldName( int aRow );
82 void SetCanonicalFieldName( int aRow, const wxString& aName );
83
84protected:
86 std::vector<BOM_FIELD> m_fields;
87};
bool IsEmptyCell(int aRow, int aCol) override
void SetValueAsBool(int aRow, int aCol, bool aValue) override
~VIEW_CONTROLS_GRID_DATA_MODEL() override=default
void SetValue(int aRow, int aCol, const wxString &aValue) override
void AppendRow(const wxString &aFieldName, const wxString &aBOMName, bool aShow, bool aGroupBy)
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
bool GetValueAsBool(int aRow, int aCol) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void SetCanonicalFieldName(int aRow, const wxString &aName)
wxString GetValue(int aRow, int aCol) override