undo: pass divecomputer number to EditSensors command

Don't access the global variable dc_number, which might
not make sense on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-05-21 21:13:32 +02:00 committed by bstoeger
parent 996f85771a
commit 297befc6f8
5 changed files with 7 additions and 7 deletions

View file

@ -312,9 +312,9 @@ int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentD
return execute_edit(new EditCylinder(index, cyl, type, currentDiveOnly));
}
void editSensors(int toCylinder, const int fromCylinder)
void editSensors(int toCylinder, int fromCylinder, int dcNr)
{
execute(new EditSensors(toCylinder, fromCylinder));
execute(new EditSensors(toCylinder, fromCylinder, dcNr));
}
// Trip editing related commands

View file

@ -114,7 +114,7 @@ enum class EditCylinderType {
GASMIX
};
int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentDiveOnly);
void editSensors(int toCylinder, const int fromCylinder);
void editSensors(int toCylinder, int fromCylinder, int dcNr);
#ifdef SUBSURFACE_MOBILE
// Edits a dive and creates a divesite (if createDs != NULL) or edits a divesite (if changeDs != NULL).
// Takes ownership of newDive and createDs!

View file

@ -1351,8 +1351,8 @@ void EditCylinder::undo()
redo();
}
EditSensors::EditSensors(int toCylinderIn, int fromCylinderIn)
: d(current_dive), dc(get_dive_dc(d, dc_number)), toCylinder(toCylinderIn), fromCylinder(fromCylinderIn)
EditSensors::EditSensors(int toCylinderIn, int fromCylinderIn, int dcNr)
: d(current_dive), dc(get_dive_dc(d, dcNr)), toCylinder(toCylinderIn), fromCylinder(fromCylinderIn)
{
if (!d || !dc)
return;

View file

@ -444,7 +444,7 @@ private:
class EditSensors : public Base
{
public:
EditSensors(int cylIndex, int fromCylinder);
EditSensors(int cylIndex, int fromCylinder, int dcNr);
private:
struct dive *d;

View file

@ -475,7 +475,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
bool ok = false;
int s = vString.toInt(&ok);
if (ok) {
Command::editSensors(index.row(), s);
Command::editSensors(index.row(), s, dc_number);
// We don't use the edit cylinder command and editing sensors is not relevant for planner
return true;
}