mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +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)
|
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();
|
CylindersModel::instance()->updateDive();
|
||||||
int lasttime = 0;
|
int lasttime = 0;
|
||||||
// we start with the first gas and see if it was changed
|
// we start with the first gas and see if it was changed
|
||||||
struct gasmix gas = backupDive.cylinder[0].gasmix;
|
struct gasmix gas = d->cylinder[0].gasmix;
|
||||||
for (int i = 0; i < backupDive.dc.samples - 1; i++) {
|
for (int i = 0; i < d->dc.samples - 1; i++) {
|
||||||
const sample &s = backupDive.dc.sample[i];
|
const sample &s = d->dc.sample[i];
|
||||||
if (s.time.seconds == 0)
|
if (s.time.seconds == 0)
|
||||||
continue;
|
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);
|
plannerModel->addStop(s.depth.mm, s.time.seconds, &gas, 0, true);
|
||||||
lasttime = s.time.seconds;
|
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
|
// copy the tanks from the current dive, or the default cylinder
|
||||||
// or an unknown cylinder
|
// or an unknown cylinder
|
||||||
// setup the cylinder widget accordingly
|
// 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)
|
DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent), mode(NOTHING), drop_stone_mode(false)
|
||||||
{
|
{
|
||||||
memset(&diveplan, 0, sizeof(diveplan));
|
memset(&diveplan, 0, sizeof(diveplan));
|
||||||
memset(&backupDive, 0, sizeof(backupDive));
|
|
||||||
startTime = QDateTime::currentDateTimeUtc();
|
startTime = QDateTime::currentDateTimeUtc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ slots:
|
||||||
void createTemporaryPlan();
|
void createTemporaryPlan();
|
||||||
void deleteTemporaryPlan();
|
void deleteTemporaryPlan();
|
||||||
void loadFromDive(dive *d);
|
void loadFromDive(dive *d);
|
||||||
void restoreBackupDive();
|
|
||||||
void emitDataChanged();
|
void emitDataChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -99,7 +98,6 @@ private:
|
||||||
Mode mode;
|
Mode mode;
|
||||||
bool recalc;
|
bool recalc;
|
||||||
QVector<divedatapoint> divepoints;
|
QVector<divedatapoint> divepoints;
|
||||||
struct dive backupDive;
|
|
||||||
void deleteTemporaryPlan(struct divedatapoint *dp);
|
void deleteTemporaryPlan(struct divedatapoint *dp);
|
||||||
QVector<sample> backupSamples; // For editing added dives.
|
QVector<sample> backupSamples; // For editing added dives.
|
||||||
QVector<QPair<int, int> > oldGases;
|
QVector<QPair<int, int> > oldGases;
|
||||||
|
|
Loading…
Reference in a new issue