summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-06 12:56:37 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-06 12:56:37 -0700
commit3d511fe26b16fa19e0d0b3376bc32fb0b54dd719 (patch)
treefb827c9a3bb3e8250f0af8ace42fca7c24fbb786 /qt-ui/diveplanner.cpp
parentcd5b2a372f70198823a7ca82a51fa38a977f1a80 (diff)
downloadsubsurface-3d511fe26b16fa19e0d0b3376bc32fb0b54dd719.tar.gz
UI restructure: remove the backupDive we no longer need
Since we have a dedicated dive that we use to display things, we can simply get the information from the current dive and use it to setup said displayed_dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp25
1 files changed, 4 insertions, 21 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 2a7bd8d40..08e67e00a 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -104,36 +104,20 @@ void DivePlannerPointsModel::setupStartTime()
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));
-
- // 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);
-
CylindersModel::instance()->updateDive();
int lasttime = 0;
// we start with the first gas and see if it was changed
- struct gasmix gas = backupDive.cylinder[0].gasmix;
- for (int i = 0; i < backupDive.dc.samples - 1; i++) {
- const sample &s = backupDive.dc.sample[i];
+ struct gasmix gas = d->cylinder[0].gasmix;
+ for (int i = 0; i < d->dc.samples - 1; i++) {
+ const sample &s = d->dc.sample[i];
if (s.time.seconds == 0)
continue;
- get_gas_from_events(&backupDive.dc, lasttime, &gas);
+ get_gas_from_events(&d->dc, lasttime, &gas);
plannerModel->addStop(s.depth.mm, s.time.seconds, &gas, 0, true);
lasttime = s.time.seconds;
}
}
-void DivePlannerPointsModel::restoreBackupDive()
-{
- memcpy(current_dive, &backupDive, sizeof(struct dive));
-}
-
// copy the tanks from the current dive, or the default cylinder
// or an unknown cylinder
// setup the cylinder widget accordingly
@@ -629,7 +613,6 @@ int DivePlannerPointsModel::rowCount(const QModelIndex &parent) const
DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), mode(NOTHING), drop_stone_mode(false)
{
memset(&diveplan, 0, sizeof(diveplan));
- memset(&backupDive, 0, sizeof(backupDive));
startTime = QDateTime::currentDateTimeUtc();
}