mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	qthelper.cpp: leave lbs rounding to QString().arg() with 'f'
The following call in weight_string():
str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
will make values in lbs larger or equal to 40 to have no fractional
part and be rounded to nearest, while values less than 40 will have one
decimal place.
fixes #412
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
			
			
This commit is contained in:
		
							parent
							
								
									1ddda0755b
								
							
						
					
					
						commit
						e7a7bd4de2
					
				
					 1 changed files with 0 additions and 4 deletions
				
			
		| 
						 | 
					@ -51,10 +51,6 @@ QString weight_string(int weight_in_grams)
 | 
				
			||||||
			str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 50) / 100);
 | 
								str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 50) / 100);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		double lbs = grams_to_lbs(weight_in_grams);
 | 
							double lbs = grams_to_lbs(weight_in_grams);
 | 
				
			||||||
		if (lbs >= 40.0)
 | 
					 | 
				
			||||||
			lbs = lrint(lbs + 0.5);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			lbs = lrint(lbs + 0.05);
 | 
					 | 
				
			||||||
		str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
 | 
							str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return (str);
 | 
						return (str);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue