From cd65c8512d2eda8177a44324ec1afd771f733236 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 2 Jul 2014 15:29:02 -0700 Subject: UI restructure: add helper function to copy and clear a dive This way we can safely copy around dives (specifically, copy the dive to be displayed / edited into the displayed_dive). Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 44449a52a..7d8416e88 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -103,8 +103,13 @@ void DivePlannerPointsModel::loadFromDive(dive *d) // We need to make a copy, because as soon as the model is modified, it will // remove all samples from the dive. memcpy(&backupDive, d, sizeof(struct dive)); - copy_samples(d, &backupDive); - copy_events(d, &backupDive); + + // this code is just adjusted for the new API, it continues to just copy the first + // DC (which here is almost certainly sufficient) + // but it should most likely use copy_dive() instead + // but this whole section needs to be rewritten, anyway + copy_samples(&d->dc, &backupDive.dc); + copy_events(&d->dc, &backupDive.dc); copy_cylinders(d, stagingDive, false); // this way the correct cylinder data is shown CylindersModel::instance()->setDive(stagingDive); int lasttime = 0; @@ -1046,9 +1051,10 @@ void DivePlannerPointsModel::createTemporaryPlan() plan(&diveplan, &cache, &tempDive, stagingDive, isPlanner(), false); MainWindow::instance()->setPlanNotes(tempDive->notes); if (mode == ADD || mode == PLAN) { - // copy the samples and events, but don't overwrite the cylinders - copy_samples(tempDive, current_dive); - copy_events(tempDive, current_dive); + // copy the samples and events of the first dive computer, but don't overwrite the cylinders + // FIXME this needs to be rewritten + copy_samples(&tempDive->dc, ¤t_dive->dc); + copy_events(&tempDive->dc, ¤t_dive->dc); copy_cylinders(tempDive, current_dive, false); } } -- cgit v1.2.3-70-g09d2