Handle tank data correctly in profile editing mode for manually added dive

This is subtle. Normally you would expect someone to edit the tank data by
simply clicking on it in the equipment tab. But a user could conceivably
edit the tank data after clicking on the profile editing button instead.
This works now as well.

This also addresses the issue that start and end pressure were not shown
in profile editing mode.

Fixes #235

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-11-14 18:36:21 +09:00
parent dfd17c7a7f
commit f6eb26dbae
3 changed files with 11 additions and 1 deletions

View file

@ -444,6 +444,8 @@ void DivePlannerPointsModel::loadFromDive(dive* d)
for(int i = 0; i < d->dc.samples-1; i++){
backupSamples.push_back( d->dc.sample[i]);
}
copy_cylinders(current_dive, stagingDive); // this way the correct cylinder data is shown
CylindersModel::instance()->setDive(stagingDive);
int lasttime = 0;
Q_FOREACH(const sample &s, backupSamples){
int o2 = 0, he = 0;
@ -453,6 +455,11 @@ void DivePlannerPointsModel::loadFromDive(dive* d)
}
}
void DivePlannerPointsModel::copyCylinders(dive *d)
{
copy_cylinders(stagingDive, d);
}
QStringList& DivePlannerPointsModel::getGasList()
{
static QStringList list;

View file

@ -37,6 +37,7 @@ public:
void tanksUpdated();
void rememberTanks();
bool tankInUse(int o2, int he);
void copyCylinders(struct dive *d);
/**
* @return the row number.
*/

View file

@ -474,7 +474,9 @@ void MainTab::acceptChanges()
if (notesBackup[curr].tags != ui.tagWidget->text())
saveTags();
if (editMode != ADD && cylindersModel->changed) {
if (editMode == MANUALLY_ADDED_DIVE) {
DivePlannerPointsModel::instance()->copyCylinders(curr);
} else if (editMode != ADD && cylindersModel->changed) {
mark_divelist_changed(TRUE);
Q_FOREACH (dive *d, notesBackup.keys()) {
for (int i = 0; i < MAX_CYLINDERS; i++) {