diff options
Diffstat (limited to 'qt-models/models.cpp')
-rw-r--r-- | qt-models/models.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
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 |