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

Joakim Bygdell j.bygdell at gmail.com
Tue Feb 9 11:39:34 PST 2016


A non-text attachment was scrubbed...
Name: 0002-QML-UI-add-function-to-get-cylinder-pressures.patch
Type: application/octet-stream
Size: 2836 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160209/fad9a750/attachment.obj>
-------------- next part --------------

> 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?
something like this?

> 
> /D

/Jocke



More information about the subsurface mailing list