Add dive property to easily test if there isn't an actual dive

Right now this just tests for zero duration, but maybe this should also
return true for positive duration and max depth of 0.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-02-14 16:26:37 -08:00
parent 58f014728c
commit 06ad45c48f
2 changed files with 11 additions and 4 deletions

View file

@ -103,6 +103,11 @@ QString DiveObjectHelper::duration() const
return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h:"), QObject::tr("min"));
}
bool DiveObjectHelper::noDive() const
{
return m_dive->duration.seconds == 0 && m_dive->dc.duration.seconds == 0;
}
QString DiveObjectHelper::depth() const
{
return get_depth_string(m_dive->dc.maxdepth.mm, true, true);

View file

@ -16,6 +16,7 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(QString location READ location CONSTANT)
Q_PROPERTY(QString gps READ gps CONSTANT)
Q_PROPERTY(QString duration READ duration CONSTANT)
Q_PROPERTY(bool noDive READ noDive CONSTANT)
Q_PROPERTY(QString depth READ depth CONSTANT)
Q_PROPERTY(QString divemaster READ divemaster CONSTANT)
Q_PROPERTY(QString buddy READ buddy CONSTANT)
@ -34,10 +35,10 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(QString maxcns READ maxcns CONSTANT)
Q_PROPERTY(QString otu READ otu CONSTANT)
Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
Q_PROPERTY(QString getCylinder READ getCylinder CONSTANT)
Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
Q_PROPERTY(QString getCylinder READ getCylinder CONSTANT)
Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
public:
DiveObjectHelper(struct dive *dive = NULL);
~DiveObjectHelper();
@ -50,6 +51,7 @@ public:
QString location() const;
QString gps() const;
QString duration() const;
bool noDive() const;
QString depth() const;
QString divemaster() const;
QString buddy() const;