From 06ad45c48f942738c0647ccc4f01d79e6a287e2e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 14 Feb 2016 16:26:37 -0800 Subject: 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 --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 5 +++++ subsurface-core/subsurface-qt/DiveObjectHelper.h | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'subsurface-core/subsurface-qt') diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index b05138980..376380b8c 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -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); diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index a4a425ac0..0584f8836 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -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; -- cgit v1.2.3-70-g09d2