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?

/D
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to