diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-11-04 12:15:27 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-04 07:21:34 -0800 |
commit | 20a9db779d3a7ba1591e8d336c6b99b80aef71de (patch) | |
tree | 9fa678ed3da32dc3b0e6006c11c78eb4a272adcf /qt-ui/diveplanner.cpp | |
parent | 06ddfc01222879ee0463affe796dba05de33b368 (diff) | |
download | subsurface-20a9db779d3a7ba1591e8d336c6b99b80aef71de.tar.gz |
Offer to save to a copy in replan mode
When replannig a dive, offer another button that creates a new
dive rather than overwriting the old. This should help in creating
several versions of a planned dive (longer/shorter, deeper/shallower
etc). Note that this makes dives that start at the same time not
influcence each other's deco.
Also, only the first of a row of simultaneous dives contributes to
the tissue loadings of later dives.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 4a299ca98..839c9d080 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -300,7 +300,9 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg connect(DivePlannerPointsModel::instance(), SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime))); // Creating (and canceling) the plan - connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); + replanButton = ui.buttonBox->addButton(tr("Save New"), QDialogButtonBox::ActionRole); + connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan())); + connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan())); connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan())); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan())); @@ -319,6 +321,11 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg setMinimumHeight(0); } +void DivePlannerWidget::setReplanButton(bool replan) +{ + replanButton->setVisible(replan); +} + void DivePlannerWidget::setupStartTime(QDateTime startTime) { ui.startTime->setTime(startTime.time()); @@ -1168,7 +1175,17 @@ void DivePlannerPointsModel::deleteTemporaryPlan() free_dps(&diveplan); } -void DivePlannerPointsModel::createPlan() +void DivePlannerPointsModel::savePlan() +{ + createPlan(false); +} + +void DivePlannerPointsModel::saveDuplicatePlan() +{ + createPlan(true); +} + +void DivePlannerPointsModel::createPlan(bool replanCopy) { // Ok, so, here the diveplan creates a dive char *cache = NULL; @@ -1188,6 +1205,15 @@ void DivePlannerPointsModel::createPlan() displayed_dive.maxdepth.mm = 0; displayed_dive.dc.maxdepth.mm = 0; fixup_dive(&displayed_dive); + if (replanCopy) { + struct dive *copy = alloc_dive(); + copy_dive(current_dive, copy); + copy->id = 0; + copy->divetrip = NULL; + if (current_dive->divetrip) + add_dive_to_trip(copy, current_dive->divetrip); + record_dive(copy); + } copy_dive(&displayed_dive, current_dive); } mark_divelist_changed(true); |