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

Dirk Hohndel dirk at hohndel.org
Tue Feb 9 10:24:14 PST 2016


On Tue, Feb 09, 2016 at 06:03:24PM +0100, Joakim Bygdell wrote:
> Since we only show the first cylinder we can also only edit the first cylinder.
> 
> Signed-off-by: Joakim Bygdell <j.bygdell at gmail.com>
> ---
>  subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 23 ++++++++++++++++++++++
>  subsurface-core/subsurface-qt/DiveObjectHelper.h   |  4 ++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
> index 2f058f4..b7542f8 100644
> --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
> +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
> @@ -33,6 +33,17 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
>  	return fmt;
>  }
>  
> +static QString getPressures(struct dive *dive, unsigned int idx)
> +{
> +	cylinder_t *cyl = &dive->cylinder[0];
> +	QString fmt;
> +	if (idx == 0)
> +		fmt = get_pressure_string(cyl->start, true);
> +	if (idx == 1)
> +		fmt = get_pressure_string(cyl->end, true);
> +	return fmt;

I find that API a bit strange - idx sounds like it would be the cylinder
number. Instead you switch between start and end. How about a bool
parameter "returnEndPressure"?




More information about the subsurface mailing list