diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-15 14:32:55 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 7c63956ee4798a835794eee8189b73e3df07594d (patch) | |
tree | 720106a3a5927e140733be5571fb8ff1fc4ca4ae /desktop-widgets/command_divesite.cpp | |
parent | b5d4d88fe596fa91a3f3491fe8acc220a0df7b72 (diff) | |
download | subsurface-7c63956ee4798a835794eee8189b73e3df07594d.tar.gz |
Undo: implement undo of geo lookup
Simply copy code of the other edit dive site functions. Here though
introduce a destructor in the undo command to free the taxonomy data.
Remove the taxonomy member of the LocationInformationWidget class,
because it is not needed anymore.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divesite.cpp')
-rw-r--r-- | desktop-widgets/command_divesite.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp index 91a6dbe81..04ee3b212 100644 --- a/desktop-widgets/command_divesite.cpp +++ b/desktop-widgets/command_divesite.cpp @@ -235,4 +235,35 @@ void EditDiveSiteLocation::undo() redo(); } +EditDiveSiteTaxonomy::EditDiveSiteTaxonomy(dive_site *dsIn, taxonomy_data &taxonomy) : ds(dsIn), + value(taxonomy) +{ + // We did a dumb copy. Erase the source to remove double references to strings. + memset(&taxonomy, 0, sizeof(taxonomy)); + setText(tr("Edit dive site taxonomy")); +} + +EditDiveSiteTaxonomy::~EditDiveSiteTaxonomy() +{ + free_taxonomy(&value); +} + +bool EditDiveSiteTaxonomy::workToBeDone() +{ + // TODO: Apparently we have no way of comparing taxonomies? + return true; +} + +void EditDiveSiteTaxonomy::redo() +{ + std::swap(value, ds->taxonomy); + emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::TAXONOMY); // Inform frontend of changed dive site. +} + +void EditDiveSiteTaxonomy::undo() +{ + // Undo and redo do the same + redo(); +} + } // namespace Command |