aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-09-02 19:11:35 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-09-03 13:35:28 -0700
commit9376721873f9897dcc2a451b5b8e0c56ca82f939 (patch)
tree3611b0c215993af6f886d6a25d5daf6676747102
parent28fe6a7b3856f1359f875f9d53d4c64e7dc1ea15 (diff)
downloadsubsurface-9376721873f9897dcc2a451b5b8e0c56ca82f939.tar.gz
desktop: warn when deleting a cylinder with sensor readings
This makes the sensors pointless and in the future, they will be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/tab-widgets/TabDiveEquipment.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
index 5105029a3..ad13e6b7e 100644
--- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
@@ -3,11 +3,14 @@
#include "maintab.h"
#include "desktop-widgets/simplewidgets.h" // For isGnome3Session()
#include "desktop-widgets/modeldelegates.h"
+#include "core/dive.h"
+#include "core/selection.h"
#include "commands/command.h"
#include "qt-models/cylindermodel.h"
#include "qt-models/weightmodel.h"
+#include <QMessageBox>
#include <QSettings>
#include <QCompleter>
@@ -162,10 +165,21 @@ void TabDiveEquipment::editCylinderWidget(const QModelIndex &index)
if (!index.isValid())
return;
- if (index.column() == CylindersModel::REMOVE)
+ if (index.column() == CylindersModel::REMOVE) {
+ int cylinder_id = cylindersModel->mapToSource(index).row();
+ for (dive *d: getDiveSelection()) {
+ if (cylinder_with_sensor_sample(d, cylinder_id)) {
+ if (QMessageBox::warning(this, tr("Remove cylinder?"),
+ tr("The deleted cylinder has sensor readings, which will be lost.\n"
+ "Do you want to continue?"),
+ QMessageBox::Yes|QMessageBox::No) != QMessageBox::Yes)
+ return;
+ }
+ }
divesEdited(Command::removeCylinder(cylindersModel->mapToSource(index).row(), false));
- else
+ } else {
ui.cylinders->edit(index);
+ }
}
void TabDiveEquipment::editWeightWidget(const QModelIndex &index)