mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
cd5b2a372f
commit
3d511fe26b
2 changed files with 4 additions and 23 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,6 @@ slots:
|
|||
void createTemporaryPlan();
|
||||
void deleteTemporaryPlan();
|
||||
void loadFromDive(dive *d);
|
||||
void restoreBackupDive();
|
||||
void emitDataChanged();
|
||||
|
||||
signals:
|
||||
|
@ -99,7 +98,6 @@ private:
|
|||
Mode mode;
|
||||
bool recalc;
|
||||
QVector<divedatapoint> divepoints;
|
||||
struct dive backupDive;
|
||||
void deleteTemporaryPlan(struct divedatapoint *dp);
|
||||
QVector<sample> backupSamples; // For editing added dives.
|
||||
QVector<QPair<int, int> > oldGases;
|
||||
|
|
Loading…
Reference in a new issue