mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
339f214384
commit
8928e54dfc
3 changed files with 20 additions and 29 deletions
|
@ -177,26 +177,6 @@ bool DivePlannerPointsModel::updateMaxDepth()
|
||||||
return (displayed_dive.maxdepth.mm != prevMaxDepth);
|
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()
|
void DivePlannerPointsModel::removeDeco()
|
||||||
{
|
{
|
||||||
bool oldrec = setRecalc(false);
|
bool oldrec = setRecalc(false);
|
||||||
|
|
|
@ -52,7 +52,6 @@ public:
|
||||||
divedatapoint at(int row);
|
divedatapoint at(int row);
|
||||||
int size();
|
int size();
|
||||||
struct diveplan &getDiveplan();
|
struct diveplan &getDiveplan();
|
||||||
QStringList &getGasList();
|
|
||||||
int lastEnteredPoint();
|
int lastEnteredPoint();
|
||||||
void removeDeco();
|
void removeDeco();
|
||||||
static bool addingDeco;
|
static bool addingDeco;
|
||||||
|
|
|
@ -36,16 +36,28 @@ GasSelectionModel *GasSelectionModel::instance()
|
||||||
return &self;
|
return &self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Remove this #include here when the issue below is fixed.
|
static QStringList getGasList()
|
||||||
#include "diveplannermodel.h"
|
{
|
||||||
|
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()
|
void GasSelectionModel::repopulate()
|
||||||
{
|
{
|
||||||
/* TODO:
|
setStringList(getGasList());
|
||||||
* 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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant GasSelectionModel::data(const QModelIndex &index, int role) const
|
QVariant GasSelectionModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
Loading…
Add table
Reference in a new issue