[PATCH 2/3] QML UI: add function to get cylinder pressures
Dirk Hohndel
dirk at hohndel.org
Tue Feb 9 10:59:34 PST 2016
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
More information about the subsurface
mailing list