Symbol Fields: move more strings to template field names usage
This commit is contained in:
parent
6a726709b5
commit
8433f94886
|
@ -341,23 +341,26 @@ void DIALOG_SYMBOL_FIELDS_TABLE::SetupColumnProperties()
|
||||||
attr->SetReadOnly( false );
|
attr->SetReadOnly( false );
|
||||||
|
|
||||||
// Set some column types to specific editors
|
// Set some column types to specific editors
|
||||||
if( m_dataModel->GetColFieldName( col ) == _( "Reference" ) )
|
if( m_dataModel->GetColFieldName( col )
|
||||||
|
== TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD ) )
|
||||||
{
|
{
|
||||||
attr->SetReadOnly();
|
attr->SetReadOnly();
|
||||||
m_grid->SetColAttr( col, attr );
|
m_grid->SetColAttr( col, attr );
|
||||||
}
|
}
|
||||||
else if( m_dataModel->GetColFieldName( col ) == _( "Footprint" ) )
|
else if( m_dataModel->GetColFieldName( col )
|
||||||
|
== TEMPLATE_FIELDNAME::GetDefaultFieldName( FOOTPRINT_FIELD ) )
|
||||||
{
|
{
|
||||||
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, wxEmptyString ) );
|
attr->SetEditor( new GRID_CELL_FPID_EDITOR( this, wxEmptyString ) );
|
||||||
m_grid->SetColAttr( col, attr );
|
m_grid->SetColAttr( col, attr );
|
||||||
}
|
}
|
||||||
else if( m_dataModel->GetColFieldName( col ) == _( "Datasheet" ) )
|
else if( m_dataModel->GetColFieldName( col )
|
||||||
|
== TEMPLATE_FIELDNAME::GetDefaultFieldName( DATASHEET_FIELD ) )
|
||||||
{
|
{
|
||||||
// set datasheet column viewer button
|
// set datasheet column viewer button
|
||||||
attr->SetEditor( new GRID_CELL_URL_EDITOR( this, Prj().SchSearchS() ) );
|
attr->SetEditor( new GRID_CELL_URL_EDITOR( this, Prj().SchSearchS() ) );
|
||||||
m_grid->SetColAttr( col, attr );
|
m_grid->SetColAttr( col, attr );
|
||||||
}
|
}
|
||||||
else if( m_dataModel->GetColFieldName( col ) == _( "Quantity" ) )
|
else if( m_dataModel->GetColFieldName( col ) == wxS( "Quantity" ) )
|
||||||
{
|
{
|
||||||
attr->SetReadOnly();
|
attr->SetReadOnly();
|
||||||
m_grid->SetColAttr( col, attr );
|
m_grid->SetColAttr( col, attr );
|
||||||
|
@ -541,6 +544,34 @@ void DIALOG_SYMBOL_FIELDS_TABLE::AddField( const wxString& aFieldName,
|
||||||
|
|
||||||
void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||||
{
|
{
|
||||||
|
// Add mandatory fields first
|
||||||
|
for( int i = 0; i < MANDATORY_FIELDS; ++i )
|
||||||
|
{
|
||||||
|
bool show = false;
|
||||||
|
bool groupBy = false;
|
||||||
|
|
||||||
|
switch( i )
|
||||||
|
{
|
||||||
|
case REFERENCE_FIELD:
|
||||||
|
case VALUE_FIELD:
|
||||||
|
case FOOTPRINT_FIELD:
|
||||||
|
show = true;
|
||||||
|
groupBy = true;
|
||||||
|
break;
|
||||||
|
case DATASHEET_FIELD:
|
||||||
|
show = true;
|
||||||
|
groupBy = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddField( TEMPLATE_FIELDNAME::GetDefaultFieldName( i ),
|
||||||
|
TEMPLATE_FIELDNAME::GetDefaultFieldName( i, true ), show, groupBy );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generated field that isn't in any symbol
|
||||||
|
AddField( wxS( "Quantity" ), _( "Qty" ), true, false );
|
||||||
|
|
||||||
|
// User fields second
|
||||||
std::set<wxString> userFieldNames;
|
std::set<wxString> userFieldNames;
|
||||||
|
|
||||||
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
|
for( unsigned i = 0; i < m_symbolsList.GetCount(); ++i )
|
||||||
|
@ -551,13 +582,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||||
userFieldNames.insert( symbol->GetFields()[j].GetName() );
|
userFieldNames.insert( symbol->GetFields()[j].GetName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AddField( _( "Reference" ), wxT( "Reference" ), true, true );
|
|
||||||
AddField( _( "Value" ), wxT( "Value" ), true, true );
|
|
||||||
AddField( _( "Footprint" ), wxT( "Footprint" ), true, true );
|
|
||||||
AddField( _( "Datasheet" ), wxT( "Datasheet" ), true, false );
|
|
||||||
AddField( _( "Quantity" ), wxT( "Qty" ), true, false );
|
|
||||||
|
|
||||||
for( const wxString& fieldName : userFieldNames )
|
for( const wxString& fieldName : userFieldNames )
|
||||||
AddField( fieldName, fieldName, true, false );
|
AddField( fieldName, fieldName, true, false );
|
||||||
|
|
||||||
|
@ -568,8 +592,6 @@ void DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames()
|
||||||
if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
|
if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
|
||||||
AddField( templateFieldname.m_Name, templateFieldname.m_Name, false, false );
|
AddField( templateFieldname.m_Name, templateFieldname.m_Name, false, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dataModel->SetFieldsOrder( m_schSettings.m_BomSettings.column_order );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1505,9 +1527,9 @@ void DIALOG_SYMBOL_FIELDS_TABLE::onBomPresetChanged( wxCommandEvent& aEvent )
|
||||||
void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
|
void DIALOG_SYMBOL_FIELDS_TABLE::doApplyBomPreset( const BOM_PRESET& aPreset )
|
||||||
{
|
{
|
||||||
// Set a good default sort
|
// Set a good default sort
|
||||||
int fieldNameCol = m_dataModel->GetFieldNameCol( _( "Reference" ) );
|
int refCol = m_dataModel->GetFieldNameCol(
|
||||||
m_dataModel->SetSorting( fieldNameCol, false );
|
TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD ) );
|
||||||
m_grid->SetSortingColumn( fieldNameCol, false );
|
m_grid->SetSortingColumn( refCol, false );
|
||||||
|
|
||||||
for( int i = 0; i < m_fieldsCtrl->GetItemCount(); i++ )
|
for( int i = 0; i < m_fieldsCtrl->GetItemCount(); i++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -205,6 +205,19 @@ void FIELDS_EDITOR_GRID_DATA_MODEL::SetValue( int aRow, int aCol, const wxString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsReference( int aCol )
|
||||||
|
{
|
||||||
|
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
||||||
|
return m_cols[aCol].m_fieldName == TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FIELDS_EDITOR_GRID_DATA_MODEL::ColIsQuantity( int aCol )
|
||||||
|
{
|
||||||
|
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
||||||
|
return m_cols[aCol].m_fieldName == wxS( "Quantity" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const DATA_MODEL_ROW& lhGroup,
|
bool FIELDS_EDITOR_GRID_DATA_MODEL::cmp( const DATA_MODEL_ROW& lhGroup,
|
||||||
const DATA_MODEL_ROW& rhGroup,
|
const DATA_MODEL_ROW& rhGroup,
|
||||||
FIELDS_EDITOR_GRID_DATA_MODEL* dataModel, int sortCol,
|
FIELDS_EDITOR_GRID_DATA_MODEL* dataModel, int sortCol,
|
||||||
|
@ -286,7 +299,7 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
||||||
const SCH_REFERENCE& rhRef )
|
const SCH_REFERENCE& rhRef )
|
||||||
|
|
||||||
{
|
{
|
||||||
int refCol = GetFieldNameCol( _( "Reference" ) );
|
int refCol = GetFieldNameCol( TEMPLATE_FIELDNAME::GetDefaultFieldName( REFERENCE_FIELD ) );
|
||||||
bool matchFound = false;
|
bool matchFound = false;
|
||||||
|
|
||||||
// First check the reference column. This can be done directly out of the
|
// First check the reference column. This can be done directly out of the
|
||||||
|
|
|
@ -111,17 +111,8 @@ public:
|
||||||
return m_rows[aRow].m_Refs;
|
return m_rows[aRow].m_Refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColIsReference( int aCol )
|
bool ColIsReference( int aCol );
|
||||||
{
|
bool ColIsQuantity( int aCol );
|
||||||
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
|
||||||
return m_cols[aCol].m_fieldName == _( "Reference" );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ColIsQuantity( int aCol )
|
|
||||||
{
|
|
||||||
wxCHECK( aCol >= 0 && aCol < (int) m_cols.size(), false );
|
|
||||||
return m_cols[aCol].m_fieldName == _( "Quantity" );
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSorting( int aCol, bool ascending )
|
void SetSorting( int aCol, bool ascending )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue