mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allow editing sensors through equipment tab
Add a column to the equipment table that shows if a sensor is attached to a tank, or which sensors would be available to attach to a tank that currently doesn't have a pressure sensor associated with it. Changing the sensor assignement can be undone. This column is hidden by default as this is a somewhat unusual activity. Signed-off-by: Michael Andreen <michael@andreen.dev> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ec96cbaab5
commit
9b4263aa87
10 changed files with 130 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "core/divelist.h"
|
||||
#include "core/fulltext.h"
|
||||
#include "core/qthelper.h" // for copy_qstring
|
||||
#include "core/sample.h"
|
||||
#include "core/selection.h"
|
||||
#include "core/subsurface-string.h"
|
||||
#include "core/tag.h"
|
||||
|
@ -1360,6 +1361,43 @@ void EditCylinder::undo()
|
|||
redo();
|
||||
}
|
||||
|
||||
EditSensors::EditSensors(int toCylinderIn, int fromCylinderIn)
|
||||
: dc(current_dc), d(current_dive), toCylinder(toCylinderIn), fromCylinder(fromCylinderIn)
|
||||
{
|
||||
if (!d || !dc)
|
||||
return;
|
||||
|
||||
setText(Command::Base::tr("Edit sensors"));
|
||||
|
||||
}
|
||||
|
||||
void EditSensors::mapSensors(int toCyl, int fromCyl)
|
||||
{
|
||||
for (int i = 0; i < dc->samples; ++i) {
|
||||
for (int s = 0; s < MAX_SENSORS; ++s) {
|
||||
if (dc->sample[i].pressure[s].mbar && dc->sample[i].sensor[s] == fromCyl)
|
||||
dc->sample[i].sensor[s] = toCyl;
|
||||
}
|
||||
}
|
||||
emit diveListNotifier.diveComputerEdited(dc);
|
||||
invalidate_dive_cache(d); // Ensure that dive is written in git_save()
|
||||
}
|
||||
|
||||
void EditSensors::undo()
|
||||
{
|
||||
mapSensors(fromCylinder, toCylinder);
|
||||
}
|
||||
|
||||
void EditSensors::redo()
|
||||
{
|
||||
mapSensors(toCylinder, fromCylinder);
|
||||
}
|
||||
|
||||
bool EditSensors::workToBeDone()
|
||||
{
|
||||
return d && dc;
|
||||
}
|
||||
|
||||
#ifdef SUBSURFACE_MOBILE
|
||||
|
||||
EditDive::EditDive(dive *oldDiveIn, dive *newDiveIn, dive_site *createDs, dive_site *editDs, location_t dsLocationIn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue