diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-05-23 20:27:19 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-06-15 11:20:49 -0700 |
commit | 03d5e641e1284b9613f605690d04faf48ac40715 (patch) | |
tree | a58f1a8157af423f9a50f0030f5ed96b86508623 /desktop-widgets/command_edit.cpp | |
parent | 1641147e7b77db69f829cf9b41de4c313d45e3ed (diff) | |
download | subsurface-03d5e641e1284b9613f605690d04faf48ac40715.tar.gz |
Undo: return number of changed dives from undo commands
To enable a "multiple dives edited" message, return the number
of edited dives from dive edit undo commands. Since there are
two kinds of these commands, viz. normal fields and tag fields,
and the former use templates, create a common base class that
can return the number of dives. Yes, the class hierarchy is
getting scarily deep! At least, this gives a tiny bit of
code-reuse.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r-- | desktop-widgets/command_edit.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp index ff0bd871a..2c9d56ba5 100644 --- a/desktop-widgets/command_edit.cpp +++ b/desktop-widgets/command_edit.cpp @@ -25,15 +25,25 @@ static std::vector<dive *> getDives(bool currentDiveOnly) return res; } -template<typename T> -EditBase<T>::EditBase(T newValue, bool currentDiveOnly) : - value(std::move(newValue)), +EditDivesBase::EditDivesBase(bool currentDiveOnly) : dives(getDives(currentDiveOnly)), selectedDives(getDiveSelection()), current(current_dive) { } +int EditDivesBase::numDives() const +{ + return dives.size(); +} + +template<typename T> +EditBase<T>::EditBase(T newValue, bool currentDiveOnly) : + EditDivesBase(currentDiveOnly), + value(std::move(newValue)) +{ +} + // This is quite hackish: we can't use virtual functions in the constructor and // therefore can't initialize the list of dives [the values of the dives are // accessed by virtual functions]. Therefore, we (mis)use the fact that workToBeDone() @@ -439,9 +449,7 @@ DiveField EditMode::fieldId() const // ***** Tag based commands ***** EditTagsBase::EditTagsBase(const QStringList &newListIn, bool currentDiveOnly) : - dives(getDives(currentDiveOnly)), - selectedDives(getDiveSelection()), - current(current_dive), + EditDivesBase(currentDiveOnly), newList(newListIn) { } |