summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-28 18:35:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commitf11ac405933f2bc124dcff05ec44dd6860cf712c (patch)
tree502d7f9880076455324bb762e011555f7f452ae2 /desktop-widgets/tab-widgets
parent45ef87954669c765cb7b317384066c6eb88dc5d3 (diff)
downloadsubsurface-f11ac405933f2bc124dcff05ec44dd6860cf712c.tar.gz
Undo: implement undo of dive mode editing
Add a new UndoCommand for dive mode editing. This one is a bit special, as the mode is associated with a dive computer (DC), not a dive. Thus the edit command has an additional parameter, viz. the index of the DC. This does not fit properly to the EditBase class, as this class isn't aware of additional parameters and therefore this parameter is not sent via signals. At the moment this doesn't matter. In any case, the semantics of editing are weird and therefore let's do the simple thing (derive from EditBase) and let's see what the future brings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp28
-rw-r--r--desktop-widgets/tab-widgets/maintab.h1
2 files changed, 14 insertions, 15 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 02e0a65be..49cf5312c 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -345,6 +345,9 @@ void MainTab::divesEdited(const QVector<dive *> &, DiveField field)
case DiveField::NOTES:
updateNotes(current_dive);
break;
+ case DiveField::MODE:
+ updateMode(current_dive);
+ break;
default:
break;
}
@@ -399,6 +402,12 @@ void MainTab::updateNotes(const struct dive *d)
}
}
+void MainTab::updateMode(struct dive *d)
+{
+ ui.DiveType->setCurrentIndex(get_dive_dc(d, dc_number)->divemode);
+ MainWindow::instance()->graphics->recalcCeiling();
+}
+
void MainTab::updateDiveInfo(bool clear)
{
ui.location->refreshDiveSiteCache();
@@ -424,7 +433,7 @@ void MainTab::updateDiveInfo(bool clear)
UPDATE_TEXT(displayed_dive, buddy);
UPDATE_TEMP(displayed_dive, airtemp);
UPDATE_TEMP(displayed_dive, watertemp);
- ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode);
+ updateMode(&displayed_dive);
if (!clear) {
struct dive_site *ds = NULL;
@@ -558,7 +567,6 @@ void MainTab::updateDiveInfo(bool clear)
}
ui.duration->setText(render_seconds_to_string(displayed_dive.duration.seconds));
ui.depth->setText(get_depth_string(displayed_dive.maxdepth, true));
- ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode);
volume_t gases[MAX_CYLINDERS] = {};
get_gas_used(&displayed_dive, gases);
@@ -795,14 +803,6 @@ void MainTab::acceptChanges()
MODIFY_DIVES(selectedDives, EDIT_VALUE(visibility));
if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin)
MODIFY_DIVES(selectedDives, EDIT_VALUE(airtemp.mkelvin));
- if (displayed_dc->divemode != current_dc->divemode) {
- MODIFY_DIVES(selectedDives,
- if (get_dive_dc(mydive, dc_number)->divemode == current_dc->divemode || copyPaste)
- get_dive_dc(mydive, dc_number)->divemode = displayed_dc->divemode;
- );
- MODIFY_DIVES(selectedDives, update_setpoint_events(mydive, get_dive_dc(mydive, dc_number)));
- do_replot = true;
- }
if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
MODIFY_DIVES(selectedDives, EDIT_VALUE(watertemp.mkelvin));
@@ -1099,12 +1099,10 @@ void MainTab::on_airtemp_textChanged(const QString &text)
void MainTab::divetype_Changed(int index)
{
- if (editMode == IGNORE)
+ if (editMode == IGNORE || !current_dive)
return;
- displayed_dc->divemode = (enum divemode_t) index;
- update_setpoint_events(&displayed_dive, displayed_dc);
- markChangedWidget(ui.DiveType);
- MainWindow::instance()->graphics->recalcCeiling();
+ Command::editMode(getSelectedDivesCurrentLast(), dc_number, (enum divemode_t)index,
+ get_dive_dc(current_dive, dc_number)->divemode);
}
void MainTab::on_watertemp_textChanged(const QString &text)
diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h
index e8fdd0ac4..2ac463aec 100644
--- a/desktop-widgets/tab-widgets/maintab.h
+++ b/desktop-widgets/tab-widgets/maintab.h
@@ -68,6 +68,7 @@ slots:
void addWeight_clicked();
void updateDiveInfo(bool clear = false);
void updateNotes(const struct dive *d);
+ void updateMode(struct dive *d);
void updateDepthDuration();
void acceptChanges();
void rejectChanges();