diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-07-02 15:29:02 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-03 09:37:43 -0700 |
commit | cd65c8512d2eda8177a44324ec1afd771f733236 (patch) | |
tree | 439b14b04abf72111efe755012a74e09b0661c99 /qt-ui/diveplanner.cpp | |
parent | b298306eb1217609e65b2817605c1115e4d4873e (diff) | |
download | subsurface-cd65c8512d2eda8177a44324ec1afd771f733236.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
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); } } |