diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2018-01-09 20:51:40 +0100 |
---|---|---|
committer | Jan Mulder <jlmulder@xs4all.nl> | 2018-01-10 11:04:24 +0100 |
commit | 8928e54dfce324185fcd22d1d32f6343c3a3f865 (patch) | |
tree | 8c50941ef012a9ed15bbbd2d84bcf1d6c28e7c0d /qt-models | |
parent | 339f21438461310797d6e277248c9d8a2f98df7d (diff) | |
download | subsurface-8928e54dfce324185fcd22d1d32f6343c3a3f865.tar.gz |
Move function to proper place
Instead of writing TODO comment blocks, just do the work, and move the
function to the proper class. Further, after review from Berthold, cleanup
the function. There is no reason that getGasList() is member of
any class. It is just a non-class helper, and as it is only used
here, a static helper.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 20 | ||||
-rw-r--r-- | qt-models/diveplannermodel.h | 1 | ||||
-rw-r--r-- | qt-models/models.cpp | 28 |
3 files changed, 20 insertions, 29 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 31c98bac7..49e977c63 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -177,26 +177,6 @@ bool DivePlannerPointsModel::updateMaxDepth() return (displayed_dive.maxdepth.mm != prevMaxDepth); } -QStringList &DivePlannerPointsModel::getGasList() -{ - static QStringList list; - list.clear(); - for (int i = 0; i < MAX_CYLINDERS; i++) { - cylinder_t *cyl = &displayed_dive.cylinder[i]; - if (cylinder_nodata(cyl)) - break; - /* Check if we have the same gasmix two or more times - * If yes return more verbose string */ - int same_gas = same_gasmix_cylinder(cyl, i, &displayed_dive, true); - if (same_gas == -1) - list.push_back(get_gas_string(cyl->gasmix)); - else - list.push_back(get_gas_string(cyl->gasmix) + QString(" (%1 %2 ").arg(tr("cyl.")).arg(i + 1) + - cyl->type.description + ")"); - } - return list; -} - void DivePlannerPointsModel::removeDeco() { bool oldrec = setRecalc(false); diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h index 7a1cdca83..dfafe2b27 100644 --- a/qt-models/diveplannermodel.h +++ b/qt-models/diveplannermodel.h @@ -52,7 +52,6 @@ public: divedatapoint at(int row); int size(); struct diveplan &getDiveplan(); - QStringList &getGasList(); int lastEnteredPoint(); void removeDeco(); static bool addingDeco; diff --git a/qt-models/models.cpp b/qt-models/models.cpp index 4f4df6425..a799b605d 100644 --- a/qt-models/models.cpp +++ b/qt-models/models.cpp @@ -36,16 +36,28 @@ GasSelectionModel *GasSelectionModel::instance() return &self; } -//TODO: Remove this #include here when the issue below is fixed. -#include "diveplannermodel.h" +static QStringList getGasList() +{ + QStringList list; + for (int i = 0; i < MAX_CYLINDERS; i++) { + cylinder_t *cyl = &displayed_dive.cylinder[i]; + if (cylinder_nodata(cyl)) + break; + /* Check if we have the same gasmix two or more times + * If yes return more verbose string */ + int same_gas = same_gasmix_cylinder(cyl, i, &displayed_dive, true); + if (same_gas == -1) + list.push_back(get_gas_string(cyl->gasmix)); + else + list.push_back(get_gas_string(cyl->gasmix) + QString(" (%1 %2 ").arg(GasSelectionModel::tr("cyl.")).arg(i + 1) + + cyl->type.description + ")"); + } + return list; +} + void GasSelectionModel::repopulate() { - /* TODO: - * getGasList shouldn't be a member of DivePlannerPointsModel, - * it has nothing to do with the current plain being calculated: - * it's internal to the current_dive. - */ - setStringList(DivePlannerPointsModel::instance()->getGasList()); + setStringList(getGasList()); } QVariant GasSelectionModel::data(const QModelIndex &index, int role) const |