memspy/Engine/Source/Sink/MemSpyEngineOutputList.cpp
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
   100         TInt maxLengthValue = 0;
   100         TInt maxLengthValue = 0;
   101 
   101 
   102         for( TInt j=0; j<count; j++ )
   102         for( TInt j=0; j<count; j++ )
   103             {
   103             {
   104             const CMemSpyEngineOutputListItem* item = iItems[ j ];
   104             const CMemSpyEngineOutputListItem* item = iItems[ j ];
   105 			if (item->Value().Length())
   105             maxLengthCaption = Max( maxLengthCaption, item->Caption().Length() );
   106 				{
   106             maxLengthValue = Max( maxLengthValue, item->Value().Length() );
   107 	            maxLengthCaption = Max( maxLengthCaption, item->Caption().Length() );
       
   108 	            maxLengthValue = Max( maxLengthValue, item->Value().Length() );
       
   109 				}
       
   110 			else
       
   111 				{
       
   112 				// If something doesn't have a value (ie it's a section header, represented as just a caption) then the caption
       
   113 				// shouldn't be factored into the maxcaptionlength. But consider it in maxlengthValue to make sure we actually
       
   114 				// make the overall buffers big enough
       
   115 				maxLengthValue = Max( maxLengthValue, item->Caption().Length() );
       
   116 				}
       
   117             }
   107             }
   118 
   108 
   119         // Second pass - real this time - to print the values
   109         // Second pass - real this time - to print the values
   120         HBufC* line = HBufC::NewLC( ( maxLengthCaption + maxLengthValue ) + 20 );
   110         HBufC* line = HBufC::NewLC( ( maxLengthCaption + maxLengthValue ) + 20 );
   121         TPtr pLine( line->Des() );
   111         TPtr pLine( line->Des() );
   129         
   119         
   130             // Create value item & replace any further tabs
   120             // Create value item & replace any further tabs
   131             HBufC* value = MemSpyEngineUtils::CleanupTextLC( item->Value() );
   121             HBufC* value = MemSpyEngineUtils::CleanupTextLC( item->Value() );
   132 
   122 
   133             // Now format the final line, with padding.
   123             // Now format the final line, with padding.
   134 			if (value->Length()) 
   124             pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
   135 				{
       
   136 	            pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
       
   137 				}
       
   138 			else
       
   139 				{
       
   140 				// items without value (ie just captions, ie section headers) aren't constrained by the maxLengthCaption restriction
       
   141 				pLine.Copy(*caption);
       
   142 				}
       
   143             pLine.Append( *value );
   125             pLine.Append( *value );
   144             CleanupStack::PopAndDestroy( 2, caption );
   126             CleanupStack::PopAndDestroy( 2, caption );
   145 
   127 
   146             // Sink output
   128             // Sink output
   147             aSink.OutputLineL( pLine );
   129             aSink.OutputLineL( pLine );