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 <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2016-01-11 16:48:46 -02:00 committed by Dirk Hohndel
parent 7a740d25a8
commit abd05f0d21
2 changed files with 12 additions and 13 deletions

View file

@ -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

View file

@ -62,8 +62,6 @@ public:
QString otu() const;
private:
QStringList m_weights;
QStringList m_cylinders;
struct dive *m_dive;
};
Q_DECLARE_METATYPE(DiveObjectHelper *)