mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 19:13:23 +00:00
undo: implement set point change undo command
This is a simple copy of the other add-event commands. It could be made more friendly by stating the pO2 value in the text. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9a4718b46f
commit
1971cfad54
5 changed files with 19 additions and 8 deletions
|
@ -339,4 +339,9 @@ void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode)
|
||||||
execute(new AddEventDivemodeSwitch(d, dcNr, seconds, divemode));
|
execute(new AddEventDivemodeSwitch(d, dcNr, seconds, divemode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2)
|
||||||
|
{
|
||||||
|
execute(new AddEventSetpointChange(d, dcNr, seconds, pO2));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Command
|
} // namespace Command
|
||||||
|
|
|
@ -108,6 +108,7 @@ void editTripNotes(dive_trip *trip, const QString &s);
|
||||||
|
|
||||||
void addEventBookmark(struct dive *d, int dcNr, int seconds);
|
void addEventBookmark(struct dive *d, int dcNr, int seconds);
|
||||||
void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
||||||
|
void addEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2);
|
||||||
|
|
||||||
} // namespace Command
|
} // namespace Command
|
||||||
|
|
||||||
|
|
|
@ -49,4 +49,10 @@ AddEventDivemodeSwitch::AddEventDivemodeSwitch(struct dive *d, int dcNr, int sec
|
||||||
setText(tr("Add dive mode switch to %1").arg(gettextFromC::tr(divemode_text_ui[divemode])));
|
setText(tr("Add dive mode switch to %1").arg(gettextFromC::tr(divemode_text_ui[divemode])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddEventSetpointChange::AddEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2) :
|
||||||
|
AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_PO2, 0, pO2.mbar, QT_TRANSLATE_NOOP("gettextFromC", "SP change")))
|
||||||
|
{
|
||||||
|
setText(tr("Add set point change")); // TODO: format pO2 value in bar or psi.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Command
|
} // namespace Command
|
||||||
|
|
|
@ -44,6 +44,11 @@ public:
|
||||||
AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AddEventSetpointChange : public AddEventBase {
|
||||||
|
public:
|
||||||
|
AddEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Command
|
} // namespace Command
|
||||||
|
|
||||||
#endif // COMMAND_EVENT_H
|
#endif // COMMAND_EVENT_H
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "commands/command.h"
|
#include "commands/command.h"
|
||||||
#include "core/metadata.h"
|
#include "core/metadata.h"
|
||||||
#include "core/tag.h"
|
#include "core/tag.h"
|
||||||
#include "core/divelist.h" // for mark_divelist_changed
|
|
||||||
|
|
||||||
double MinMaxAvgWidget::average() const
|
double MinMaxAvgWidget::average() const
|
||||||
{
|
{
|
||||||
|
@ -176,13 +175,8 @@ RenumberDialog::RenumberDialog(QWidget *parent) : QDialog(parent), selectedOnly(
|
||||||
|
|
||||||
void SetpointDialog::buttonClicked(QAbstractButton *button)
|
void SetpointDialog::buttonClicked(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
|
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()),
|
Command::addEventSetpointChange(d, dcNr, time, pressure_t { (int)(1000.0 * ui.spinbox->value()) });
|
||||||
QT_TRANSLATE_NOOP("gettextFromC", "SP change"));
|
|
||||||
invalidate_dive_cache(current_dive);
|
|
||||||
}
|
|
||||||
mark_divelist_changed(true);
|
|
||||||
MainWindow::instance()->graphics->replot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetpointDialog::SetpointDialog(struct dive *dIn, int dcNrIn, int seconds) : QDialog(MainWindow::instance()),
|
SetpointDialog::SetpointDialog(struct dive *dIn, int dcNrIn, int seconds) : QDialog(MainWindow::instance()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue