From 5742bfb8cc827b8d763743351bb50d2bb499c021 Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Mon, 16 Jul 2012 21:49:04 +0300 Subject: [PATCH] Fix eeschema single part per line bom generation. --- eeschema/dialogs/dialog_build_BOM.cpp | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/eeschema/dialogs/dialog_build_BOM.cpp b/eeschema/dialogs/dialog_build_BOM.cpp index e034c55dc7..f0f9c8d070 100644 --- a/eeschema/dialogs/dialog_build_BOM.cpp +++ b/eeschema/dialogs/dialog_build_BOM.cpp @@ -468,7 +468,7 @@ void DIALOG_BUILD_BOM::CreatePartsList( ) cmplist.RemoveSubComponentsFromList(); // sort component list by value - cmplist.SortByValueAndRef( ); + cmplist.SortByValueOnly( ); PrintComponentsListByPart( f, cmplist, false ); fclose( f ); @@ -872,14 +872,14 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST while( index < aList.GetCount() ) { SCH_COMPONENT *component = aList[index].GetComponent(); - wxString referenceListStr; + wxArrayString referenceStrList; int qty = 1; - referenceListStr.append( aList[index].GetRef() ); + referenceStrList.Add( aList[index].GetRef() ); for( unsigned int i = index+1; i < aList.GetCount(); ) { if( *(aList[i].GetComponent()) == *component ) { - referenceListStr.append( wxT( " " ) + aList[i].GetRef() ); + referenceStrList.Add( aList[i].GetRef() ); aList.RemoveItem( i ); qty++; } @@ -887,10 +887,22 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* aFile, SCH_REFERENCE_LIST i++; // Increment index only when current item is not removed from the list } - // Write value, quantity and list of references - fprintf( aFile, "%15s%c%3d%c\"%s\"", TO_UTF8( component->GetField( VALUE )->GetText() ), - s_ExportSeparatorSymbol, qty, - s_ExportSeparatorSymbol, TO_UTF8( referenceListStr ) ); + referenceStrList.Sort( RefDesStringCompare ); // Sort references for this component + + // Write value, quantity + fprintf( aFile, "%15s%c%3d", TO_UTF8( component->GetField( VALUE )->GetText() ), + s_ExportSeparatorSymbol, qty ); + + // Write list of references + for( int i = 0; i < referenceStrList.Count(); i++ ) + { + if( i == 0 ) + fprintf( aFile, "%c\"%s", s_ExportSeparatorSymbol, TO_UTF8( referenceStrList[i] ) ); + else + fprintf( aFile, " %s", TO_UTF8( referenceStrList[i] ) ); + } + if( referenceStrList.Count() ) + fprintf( aFile, "\"" ); // Write the rest of the fields if required #if defined( KICAD_GOST )