[PATCH 2/3] QML UI: add function to get cylinder pressures

Joakim Bygdell j.bygdell at gmail.com
Tue Feb 9 11:01:20 PST 2016


> On 09 Feb 2016, at 19:59, Dirk Hohndel <dirk at hohndel.org> wrote:
> 
> On Tue, Feb 09, 2016 at 07:52:03PM +0100, Joakim Bygdell wrote:
>> 
>> +static QString getPressures(struct dive *dive, bool returnPressures)
>> +{
>> +	cylinder_t *cyl = &dive->cylinder[0];
>> +	QString fmt;
>> +	if (returnPressures == 0)
>> +		fmt = get_pressure_string(cyl->start, true);
>> +	if (returnPressures == 1)
>> +		fmt = get_pressure_string(cyl->end, true);
> 
> We don't usually test a bool for == 0/1
> 
> :-)
> 
> How about you create an enum "returnPressureSelector" with values
> "START_PRESSURE" and "END_PRESSURE"?
> 
> Then these calls become even prettier:
> 
>> +
>> +QString DiveObjectHelper::startPressure() const
>> +{
>> +	QString startPressure = getPressures(m_dive, 0);
> 
> 	getPressures(m_dive, START_PRESSURE);
> 
>> +	return startPressure;
>> +}
>> +
>> +QString DiveObjectHelper::endPressure() const
>> +{
>> +	QString endPressure = getPressures(m_dive, 1);
> 
> 	getPressures(m_dive, END_PRESSURE);
> 
>> +	return endPressure;
> 
> Make sense?
Fully.

> 
> /D

/Jocke



More information about the subsurface mailing list