Symbol Fields Table / BOM Export: handle variable resolution
This commit is contained in:
parent
2dcbc10a09
commit
9f62e88477
|
@ -139,9 +139,21 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, i
|
|||
return INDETERMINATE_STATE;
|
||||
}
|
||||
|
||||
wxString refFieldValue;
|
||||
|
||||
if( resolveVars )
|
||||
{
|
||||
SCH_FIELD* field = ref.GetSymbol()->GetFieldByName( m_cols[aCol].m_fieldName );
|
||||
|
||||
if( field != nullptr )
|
||||
refFieldValue = field->GetShownText( &ref.GetSheetPath(), false );
|
||||
}
|
||||
else
|
||||
refFieldValue = m_dataStore[symbolID][m_cols[aCol].m_fieldName];
|
||||
|
||||
if( &ref == &group.m_Refs.front() )
|
||||
fieldValue = m_dataStore[symbolID][m_cols[aCol].m_fieldName];
|
||||
else if( fieldValue != m_dataStore[symbolID][m_cols[aCol].m_fieldName] )
|
||||
fieldValue = refFieldValue;
|
||||
else if( fieldValue != refFieldValue )
|
||||
return INDETERMINATE_STATE;
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +319,6 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
|||
matchFound = true;
|
||||
}
|
||||
|
||||
const KIID& lhRefID = lhRef.GetSymbol()->m_Uuid;
|
||||
const KIID& rhRefID = rhRef.GetSymbol()->m_Uuid;
|
||||
|
||||
// Now check all the other columns. This must be done out of the dataStore
|
||||
// for the refresh button to work after editing.
|
||||
for( size_t i = 0; i < m_cols.size(); ++i )
|
||||
|
@ -322,10 +331,18 @@ bool FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch( const SCH_REFERENCE& lhRef,
|
|||
continue;
|
||||
|
||||
wxString fieldName = m_cols[i].m_fieldName;
|
||||
SCH_FIELD* lhField = lhRef.GetSymbol()->GetFieldByName( m_cols[i].m_fieldName );
|
||||
SCH_FIELD* rhField = rhRef.GetSymbol()->GetFieldByName( m_cols[i].m_fieldName );
|
||||
|
||||
if( m_dataStore[lhRefID][fieldName] != m_dataStore[rhRefID][fieldName] )
|
||||
if( lhField == nullptr || rhField == nullptr )
|
||||
return false;
|
||||
|
||||
if( lhField->GetShownText( &lhRef.GetSheetPath(), false )
|
||||
!= rhField->GetShownText( &rhRef.GetSheetPath(), false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
matchFound = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -912,6 +912,18 @@ SCH_FIELD* SCH_SYMBOL::GetFieldById( int aFieldId )
|
|||
}
|
||||
|
||||
|
||||
SCH_FIELD* SCH_SYMBOL::GetFieldByName( const wxString& aFieldName )
|
||||
{
|
||||
for( size_t ii = 0; ii < m_fields.size(); ++ii )
|
||||
{
|
||||
if( m_fields[ii].GetName() == aFieldName )
|
||||
return &m_fields[ii];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
wxString SCH_SYMBOL::GetFieldText( const wxString& aFieldName ) const
|
||||
{
|
||||
for( const SCH_FIELD& field : m_fields )
|
||||
|
|
|
@ -405,6 +405,15 @@ public:
|
|||
*/
|
||||
SCH_FIELD* GetFieldById( int aFieldId );
|
||||
|
||||
/**
|
||||
* Return a field in this symbol.
|
||||
*
|
||||
* @param aFieldName is the name of the field
|
||||
*
|
||||
* @return is the field with \a aFieldName or NULL if the field does not exist.
|
||||
*/
|
||||
SCH_FIELD* GetFieldByName( const wxString& aFieldName );
|
||||
|
||||
/**
|
||||
* Search for a field named \a aFieldName and returns text associated with this field.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue