summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-03 23:17:08 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit9a4718b46f5fa74c7c67a92d0c09ab805f364e12 (patch)
treee344542764813c1b6dfb41e945d8cb6e5bac3c91
parentadb53f9c18070e524a2635c5a1d983556f21d5ea (diff)
downloadsubsurface-9a4718b46f5fa74c7c67a92d0c09ab805f364e12.tar.gz
undo: switch SetpointDialog from divecomputer to dive + dc-number
Since pointers to divecomputers may not be stable, the undo commands take a dive + a divecomputer number. Update the SetpointDialog accordingly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/simplewidgets.cpp8
-rw-r--r--desktop-widgets/simplewidgets.h5
-rw-r--r--profile-widget/profilewidget2.cpp2
3 files changed, 8 insertions, 7 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index 4b85a8b50..c31c93676 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -176,8 +176,8 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(
void SetpointDialog::buttonClicked(QAbstractButton *button)
{
- if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole && dc) {
- add_event(dc, time, SAMPLE_EVENT_PO2, 0, (int)(1000.0 * ui.spinbox->value()),
+ if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
+ add_event(get_dive_dc(d, dcNr), time, SAMPLE_EVENT_PO2, 0, (int)(1000.0 * ui.spinbox->value()),
QT_TRANSLATE_NOOP("gettextFromC", "SP change"));
invalidate_dive_cache(current_dive);
}
@@ -185,8 +185,8 @@ void SetpointDialog::buttonClicked(QAbstractButton *button)
MainWindow::instance()->graphics->replot();
}
-SetpointDialog::SetpointDialog(struct divecomputer *dcIn, int seconds) : QDialog(MainWindow::instance()),
- dc(dcIn), time(seconds < 0 ? 0 : seconds)
+SetpointDialog::SetpointDialog(struct dive *dIn, int dcNrIn, int seconds) : QDialog(MainWindow::instance()),
+ d(dIn), dcNr(dcNrIn), time(seconds < 0 ? 0 : seconds)
{
ui.setupUi(this);
connect(ui.buttonBox, &QDialogButtonBox::clicked, this, &SetpointDialog::buttonClicked);
diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h
index e293f352c..421695815 100644
--- a/desktop-widgets/simplewidgets.h
+++ b/desktop-widgets/simplewidgets.h
@@ -65,14 +65,15 @@ private:
class SetpointDialog : public QDialog {
Q_OBJECT
public:
- SetpointDialog(struct divecomputer *divecomputer, int time);
+ SetpointDialog(struct dive *d, int dcNr, int time);
private
slots:
void buttonClicked(QAbstractButton *button);
private:
Ui::SetpointDialog ui;
- struct divecomputer *dc;
+ struct dive *d;
+ int dcNr;
int time;
};
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 555305817..76b3c9afb 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1611,7 +1611,7 @@ void ProfileWidget2::addDivemodeSwitch(int seconds, int divemode)
void ProfileWidget2::addSetpointChange(int seconds)
{
- SetpointDialog dialog(current_dc, seconds);
+ SetpointDialog dialog(current_dive, dc_number, seconds);
dialog.exec();
}