From f7cd3e780cdc77180ce279c95322de2095192657 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 1 Nov 2013 11:48:34 -0400 Subject: Enable editing a dive that was manually entered. This patch enables editing a dive that was manually entered, it doesn't cover dive plans yet because on the plan I need to figure out what are the 'user-entered' points, and what are the algorithm point. and I feel lazy. =p One last thing that's missing is to revert the dive to the previous condition if the user cancels the edition, currently canceling and applying ok is the same thing. Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'qt-ui/diveplanner.cpp') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 2078ff8a8..f4bbfafa0 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -425,6 +425,28 @@ void DivePlannerPointsModel::createSimpleDive() plannerModel->addStop(M_OR_FT(5,15), 45 * 60, tr("Air"), 0); } +void DivePlannerPointsModel::loadFromDive(dive* d) +{ + int totalSamples = d->dc.samples -2; // removes begin and end. + + /* We need to make a copy, because + * as soon as the model is modified, it will + * remove all samples from the current dive. + * + * TODO: keep a backup of the values, + * so we can restore. + * */ + QList > values; + for(int i = 1; i < d->dc.samples-1; i++){ + struct sample &s = d->dc.sample[i]; + values.append( qMakePair(s.depth.mm, s.time.seconds)); + } + + for(int i = 0; i < totalSamples; i++){ + plannerModel->addStop(values[i].first, values[i].second, tr("Air"), 0); + } +} + void DivePlannerGraphics::prepareSelectGas() { currentGasChoice = static_cast(sender()); -- cgit v1.2.3-70-g09d2