7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:31:42 +00:00

Export comma-delimited values instead of "-- mixed values --".

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17912
This commit is contained in:
Jeff Young 2025-01-06 11:55:08 +00:00
parent c2a3bfa477
commit 8481eb8cf5
2 changed files with 24 additions and 4 deletions

View File

@ -173,9 +173,11 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( int aRow, int aCol )
wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, int aCol,
const wxString& refDelimiter,
const wxString& refRangeDelimiter,
bool resolveVars )
bool resolveVars,
bool listMixedValues )
{
std::vector<SCH_REFERENCE> references;
std::set<wxString> mixedValues;
wxString fieldValue;
for( const SCH_REFERENCE& ref : group.m_Refs )
@ -209,13 +211,30 @@ wxString FIELDS_EDITOR_GRID_DATA_MODEL::GetValue( const DATA_MODEL_ROW& group, i
refFieldValue = m_dataStore[symbolID][m_cols[aCol].m_fieldName];
}
if( &ref == &group.m_Refs.front() )
if( listMixedValues )
mixedValues.insert( refFieldValue );
else if( &ref == &group.m_Refs.front() )
fieldValue = refFieldValue;
else if( fieldValue != refFieldValue )
return INDETERMINATE_STATE;
}
}
if( listMixedValues && mixedValues.size() > 1 )
{
fieldValue = wxEmptyString;
for( const wxString& value : mixedValues )
{
if( value.IsEmpty() )
continue;
else if( fieldValue.IsEmpty() )
fieldValue = value;
else
fieldValue += "," + value;
}
}
if( ColIsReference( aCol ) || ColIsQuantity( aCol ) || ColIsItemNumber( aCol ) )
{
// Remove duplicates (other units of multi-unit parts)

View File

@ -157,12 +157,13 @@ public:
wxString GetValue( const DATA_MODEL_ROW& group, int aCol,
const wxString& refDelimiter = wxT( ", " ),
const wxString& refRangDelimiter = wxT( "-" ),
bool resolveVars = false );
bool resolveVars = false,
bool listMixedValues = false );
wxString GetExportValue( int aRow, int aCol, const wxString& refDelimiter,
const wxString& refRangeDelimiter )
{
return GetValue( m_rows[aRow], aCol, refDelimiter, refRangeDelimiter, true );
return GetValue( m_rows[aRow], aCol, refDelimiter, refRangeDelimiter, true, true );
}
void SetValue( int aRow, int aCol, const wxString& aValue ) override;