summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-27 18:40:32 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit0732bb2302418fe07064ea04df3435ab527fbd00 (patch)
tree0b57d224c0dd6cd4016be47e9c39a366920c859d /desktop-widgets
parent04ce908e8ed6239b8f143b3892da0dcdaa6e8262 (diff)
downloadsubsurface-0732bb2302418fe07064ea04df3435ab527fbd00.tar.gz
undo: remove TabDiveWidget::acceptChanges and rejectChanges
Since cylinders are now edited using the undo system, these functions are not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveEquipment.cpp81
-rw-r--r--desktop-widgets/tab-widgets/TabDiveEquipment.h2
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp8
3 files changed, 0 insertions, 91 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
index ea2d910ef..c5601f1ce 100644
--- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp
@@ -183,87 +183,6 @@ void TabDiveEquipment::editWeightWidget(const QModelIndex &index)
ui.weights->edit(index);
}
-// tricky little macro to edit all the selected dives
-// loop ove all DIVES and do WHAT.
-#define MODIFY_DIVES(DIVES, WHAT) \
- do { \
- for (dive *mydive: DIVES) { \
- invalidate_dive_cache(mydive); \
- WHAT; \
- } \
- mark_divelist_changed(true); \
- } while (0)
-
-// Get the list of selected dives, but put the current dive at the last position of the vector
-static QVector<dive *> getSelectedDivesCurrentLast()
-{
- QVector<dive *> res;
- struct dive *d;
- int i;
- for_each_dive (i, d) {
- if (d->selected && d != current_dive)
- res.append(d);
- }
- res.append(current_dive);
- return res;
-}
-
-// TODO: This is a temporary functions until undo of cylinders is implemented.
-// Therefore it is not worth putting it in a header.
-extern bool cylinders_equal(const dive *d1, const dive *d2);
-
-void TabDiveEquipment::acceptChanges()
-{
- bool do_replot = false;
-
- // now check if something has changed and if yes, edit the selected dives that
- // were identical with the master dive shown (and mark the divelist as changed)
- struct dive *cd = current_dive;
-
- // Get list of selected dives, but put the current dive last;
- // this is required in case the invocation wants to compare things
- // to the original value in current_dive like it should
- QVector<dive *> selectedDives = getSelectedDivesCurrentLast();
-
- if (cylindersModel->model()->changed) {
- mark_divelist_changed(true);
- MODIFY_DIVES(selectedDives,
- // if we started out with the same cylinder description (for multi-edit) or if we do copt & paste
- // make sure that we have the same cylinder type and copy the gasmix, but DON'T copy the start
- // and end pressures (those are per dive after all)
- if (cylinders_equal(mydive, cd) && mydive != cd)
- copy_cylinder_types(&displayed_dive, cd);
- copy_cylinders(&displayed_dive.cylinders, &cd->cylinders);
- );
- /* if cylinders changed we may have changed gas change events
- * and sensor idx in samples as well
- * - so far this is ONLY supported for a single selected dive */
- struct divecomputer *tdc = &current_dive->dc;
- struct divecomputer *sdc = &displayed_dive.dc;
- while(tdc && sdc) {
- free_events(tdc->events);
- copy_events(sdc, tdc);
- free(tdc->sample);
- copy_samples(sdc, tdc);
- tdc = tdc->next;
- sdc = sdc->next;
- }
- do_replot = true;
- }
-
- if (do_replot)
- MainWindow::instance()->graphics->replot();
-
- cylindersModel->model()->changed = false;
-}
-
-void TabDiveEquipment::rejectChanges()
-{
- cylindersModel->model()->changed = false;
- cylindersModel->updateDive(current_dive);
- weightModel->updateDive(current_dive);
-}
-
void TabDiveEquipment::divesEdited(int i)
{
// No warning if only one dive was edited
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.h b/desktop-widgets/tab-widgets/TabDiveEquipment.h
index 28e6235d1..3576b449e 100644
--- a/desktop-widgets/tab-widgets/TabDiveEquipment.h
+++ b/desktop-widgets/tab-widgets/TabDiveEquipment.h
@@ -21,8 +21,6 @@ public:
~TabDiveEquipment();
void updateData() override;
void clear() override;
- void acceptChanges();
- void rejectChanges();
void divesEdited(int i);
void closeWarning();
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 252e135a6..ea20219ce 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -534,10 +534,6 @@ void MainTab::acceptChanges()
ui.dateEdit->setEnabled(true);
hideMessage();
- // TODO: This is a temporary hack until the equipment tab is included in the undo system:
- // The equipment tab is hardcoded at the first place of the "extra widgets".
- ((TabDiveEquipment *)extraWidgets[0])->acceptChanges();
-
if (lastMode == MANUALLY_ADDED_DIVE) {
MainWindow::instance()->showProfile();
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
@@ -606,10 +602,6 @@ void MainTab::rejectChanges()
clear_dive(&displayed_dive);
updateDiveInfo();
- // TODO: This is a temporary hack until the equipment tab is included in the undo system:
- // The equipment tab is hardcoded at the first place of the "extra widgets".
- ((TabDiveEquipment *)extraWidgets[0])->rejectChanges();
-
// the user could have edited the location and then canceled the edit
// let's get the correct location back in view
MapWidget::instance()->centerOnDiveSite(current_dive ? current_dive->dive_site : nullptr);