Symbol Fields Table: various bug and coverity fixes
This commit is contained in:
parent
791a9e6c78
commit
247c2edbed
|
@ -50,6 +50,7 @@ Ian McInerney <ian.s.mcinerney[at]ieee-dot-org>
|
|||
Thomas Pointhuber <thomas.pointhuber[at]gmx-dot-at>
|
||||
Roberto Fernandez Bautista <roberto.fer.bau[at]gmail-dot-com>
|
||||
Mikołaj Wielgus <wielgusmikolaj[at]gmail-dot-com>
|
||||
Mike Williams <mike[at]mikebwilliams-dot-com>
|
||||
|
||||
See git repo on GitLab for contributors at
|
||||
https://gitlab.com/kicad/code/kicad/-/graphs/master
|
||||
|
|
|
@ -511,6 +511,9 @@ void DIALOG_SYMBOL_FIELDS_TABLE::AddField( const wxString& aFieldName, const wxS
|
|||
fieldsCtrlRow.push_back( wxVariant( aFieldName ) );
|
||||
|
||||
m_fieldsCtrl->AppendItem( fieldsCtrlRow );
|
||||
|
||||
wxGridTableMessage msg( m_dataModel, wxGRIDTABLE_NOTIFY_COLS_APPENDED, 1 );
|
||||
m_grid->ProcessTableMessage( msg );
|
||||
}
|
||||
|
||||
|
||||
|
@ -594,9 +597,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnAddField( wxCommandEvent& event )
|
|||
|
||||
AddField( fieldName, fieldName, true, false, true );
|
||||
|
||||
wxGridTableMessage msg( m_dataModel, wxGRIDTABLE_NOTIFY_COLS_APPENDED, 1 );
|
||||
m_grid->ProcessTableMessage( msg );
|
||||
|
||||
wxGridCellAttr* attr = new wxGridCellAttr;
|
||||
m_grid->SetColAttr( m_dataModel->GetColsCount() - 1, attr );
|
||||
m_grid->SetColFormatCustom( m_dataModel->GetColsCount() - 1, wxGRID_VALUE_STRING );
|
||||
|
@ -1298,11 +1298,11 @@ void DIALOG_SYMBOL_FIELDS_TABLE::syncBomPresetSelection()
|
|||
// Only compare shown or grouped fields
|
||||
std::vector<BOM_FIELD> A, B;
|
||||
|
||||
for( auto field : preset.fieldsOrdered )
|
||||
for( const BOM_FIELD& field : preset.fieldsOrdered )
|
||||
if( field.show || field.groupBy )
|
||||
A.emplace_back( field );
|
||||
|
||||
for( auto field : current.fieldsOrdered )
|
||||
for( const BOM_FIELD& field : current.fieldsOrdered )
|
||||
if( field.show || field.groupBy )
|
||||
B.emplace_back( field );
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ const std::vector<BOM_FIELD> FIELDS_EDITOR_GRID_DATA_MODEL::GetFieldsOrdered()
|
|||
{
|
||||
std::vector<BOM_FIELD> fields;
|
||||
|
||||
for( auto col : m_cols )
|
||||
for( const DATA_MODEL_COL& col : m_cols )
|
||||
fields.push_back( { col.m_fieldName, col.m_label, col.m_show, col.m_group } );
|
||||
|
||||
return fields;
|
||||
|
@ -303,6 +303,9 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
|||
int refCol = GetFieldNameCol( TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD ) );
|
||||
bool matchFound = false;
|
||||
|
||||
if( refCol == -1 )
|
||||
return false;
|
||||
|
||||
// First check the reference column. This can be done directly out of the
|
||||
// SCH_REFERENCEs as the references can't be edited in the grid.
|
||||
if( m_cols[refCol].m_group )
|
||||
|
@ -609,7 +612,10 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::ApplyBomPreset( const BOM_PRESET& aPreset )
|
|||
// Add any missing fields, if the user doesn't add any data
|
||||
// they won't be saved to the symbols anywa
|
||||
if( col == -1 )
|
||||
{
|
||||
AddColumn( field.name, field.label, true );
|
||||
col = GetFieldNameCol( field.name );
|
||||
}
|
||||
else
|
||||
SetColLabelValue( col, field.label );
|
||||
|
||||
|
@ -660,18 +666,19 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::Export( const BOM_FMT_PRESET& settings )
|
|||
if( m_cols.empty() )
|
||||
return out;
|
||||
|
||||
size_t last_col = m_cols.size() - 1;
|
||||
int last_col = -1;
|
||||
|
||||
// Find the location for the line terminator
|
||||
for( size_t col = m_cols.size() - 1; col >= 0; --col )
|
||||
for( size_t col = 0; col < m_cols.size(); col++ )
|
||||
{
|
||||
if( m_cols[col].m_show )
|
||||
{
|
||||
last_col = col;
|
||||
break;
|
||||
}
|
||||
last_col = (int) col;
|
||||
}
|
||||
|
||||
// No shown columns
|
||||
if( last_col == -1 )
|
||||
return out;
|
||||
|
||||
auto formatField = [&]( wxString field, bool last ) -> wxString
|
||||
{
|
||||
if( !settings.keepLineBreaks )
|
||||
|
@ -699,7 +706,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::Export( const BOM_FMT_PRESET& settings )
|
|||
if( !m_cols[col].m_show )
|
||||
continue;
|
||||
|
||||
out.Append( formatField( m_cols[col].m_label, col == last_col ) );
|
||||
out.Append( formatField( m_cols[col].m_label, col == (size_t) last_col ) );
|
||||
}
|
||||
|
||||
// Data rows
|
||||
|
@ -717,7 +724,7 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::Export( const BOM_FMT_PRESET& settings )
|
|||
// Get the unanottated version of the field, e.g. no "> " or "v " by
|
||||
out.Append( formatField( GetExportValue( (int) row, (int) col, settings.refDelimiter,
|
||||
settings.refRangeDelimiter ),
|
||||
col == last_col ) );
|
||||
col == (size_t) last_col ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue