From abd05f0d21ab98ad11daaeac63243c8a428b4881 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 11 Jan 2016 16:48:46 -0200 Subject: [PATCH] Simplify: remove weigths and cylinders. This finishes the first round of Simplication patches for the QML basecode. The second one will be about the preferences. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- .../subsurface-qt/DiveObjectHelper.cpp | 23 ++++++++++--------- .../subsurface-qt/DiveObjectHelper.h | 2 -- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index a03bd311c..51831efd8 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -36,11 +36,6 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_dive(d) { - for (int i = 0; i < MAX_CYLINDERS; i++) - m_cylinders << getFormattedCylinder(d, i); - - for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) - m_weights << getFormattedWeight(d, i); } DiveObjectHelper::~DiveObjectHelper() @@ -186,14 +181,17 @@ QString DiveObjectHelper::sac() const QStringList DiveObjectHelper::weights() const { - return m_weights; + QStringList weights; + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + weights << getFormattedWeight(m_dive, i); + return weights; } QString DiveObjectHelper::weight(int idx) const { - if (idx < 0 || idx > m_weights.size() - 1) + if ( (idx < 0) || idx > MAX_WEIGHTSYSTEMS ) return QString(EMPTY_DIVE_STRING); - return m_weights.at(idx); + return getFormattedWeight(m_dive, idx); } QString DiveObjectHelper::suit() const @@ -203,14 +201,17 @@ QString DiveObjectHelper::suit() const QStringList DiveObjectHelper::cylinders() const { - return m_cylinders; + QStringList cylinders; + for (int i = 0; i < MAX_CYLINDERS; i++) + cylinders << getFormattedCylinder(m_dive, i); + return cylinders; } QString DiveObjectHelper::cylinder(int idx) const { - if (idx < 0 || idx > m_cylinders.size() - 1) + if ( (idx < 0) || idx > MAX_CYLINDERS) return QString(EMPTY_DIVE_STRING); - return m_cylinders.at(idx); + return getFormattedCylinder(m_dive, idx); } QString DiveObjectHelper::trip() const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 5702535ba..4d1e1acb2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -62,8 +62,6 @@ public: QString otu() const; private: - QStringList m_weights; - QStringList m_cylinders; struct dive *m_dive; }; Q_DECLARE_METATYPE(DiveObjectHelper *)