mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Used gas in dive planner points: Support for multiple cyl with same gas
In the planner if one adds two or more cylinders with the same gasmix (e.g. back gas and bottom stage 18/45) the drop down and data in the used gas column of the planner points table will be filled with a more verbose string mentioning also the cyl number and the cyl type description. Makes it easier in such a case to select the right cylinder. Introduces also a helper function which tells you if there is another cylinder with the same gasmix as the provided cylinder. This also has an option if it should consider unused cylinders or not. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
parent
8fd1c72f04
commit
c29456f0bb
4 changed files with 39 additions and 32 deletions
|
@ -139,7 +139,6 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
int mapping[MAX_CYLINDERS];
|
||||
int same_gas = -1;
|
||||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||
struct gasmix *mygas = &cyl->gasmix;
|
||||
|
||||
switch (role) {
|
||||
case Qt::BackgroundRole: {
|
||||
|
@ -233,15 +232,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
case Qt::DecorationRole:
|
||||
case Qt::SizeHintRole:
|
||||
if (index.column() == REMOVE) {
|
||||
same_gas = -1;
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
mapping[i] = i;
|
||||
if (i == index.row() || cylinder_none(&displayed_dive.cylinder[i]))
|
||||
continue;
|
||||
struct gasmix *gas2 = &displayed_dive.cylinder[i].gasmix;
|
||||
if (gasmix_distance(mygas, gas2) == 0 && is_cylinder_used(&displayed_dive, i))
|
||||
same_gas = i;
|
||||
}
|
||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
|
@ -256,15 +248,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
case Qt::ToolTipRole:
|
||||
switch (index.column()) {
|
||||
case REMOVE:
|
||||
same_gas = -1;
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
mapping[i] = i;
|
||||
if (i == index.row() || cylinder_none(&displayed_dive.cylinder[i]))
|
||||
continue;
|
||||
struct gasmix *gas2 = &displayed_dive.cylinder[i].gasmix;
|
||||
if (gasmix_distance(mygas, gas2) == 0 && is_cylinder_used(&displayed_dive, i))
|
||||
same_gas = i;
|
||||
}
|
||||
same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
|
@ -558,17 +543,9 @@ void CylindersModel::remove(const QModelIndex &index)
|
|||
if (index.column() != REMOVE) {
|
||||
return;
|
||||
}
|
||||
int same_gas = -1;
|
||||
cylinder_t *cyl = &displayed_dive.cylinder[index.row()];
|
||||
struct gasmix *mygas = &cyl->gasmix;
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||
mapping[i] = i;
|
||||
if (i == index.row() || cylinder_none(&displayed_dive.cylinder[i]))
|
||||
continue;
|
||||
struct gasmix *gas2 = &displayed_dive.cylinder[i].gasmix;
|
||||
if (gasmix_distance(mygas, gas2) == 0 && is_cylinder_used(&displayed_dive, i))
|
||||
same_gas = i;
|
||||
}
|
||||
int same_gas = same_gasmix_cylinder(cyl, index.row(), &displayed_dive, false);
|
||||
|
||||
if ((in_planner() || same_gas == -1) &&
|
||||
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
|
||||
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
|
||||
|
@ -604,6 +581,7 @@ void CylindersModel::remove(const QModelIndex &index)
|
|||
dc_cylinder_renumber(&displayed_dive, dc, mapping);
|
||||
dc = dc->next;
|
||||
}
|
||||
dataChanged(index, index);
|
||||
}
|
||||
|
||||
void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue