diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-06-23 12:13:25 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-06-23 20:08:46 +0200 |
commit | 4716c820322dd654e43dc47087866b066b2e5910 (patch) | |
tree | fe35e14b3da25e8dad84427cf1b0de2f4de86396 /desktop-widgets/command_divelist.h | |
parent | e1abf9485cf59f1b8cb79d827fa386af48f095a4 (diff) | |
download | subsurface-4716c820322dd654e43dc47087866b066b2e5910.tar.gz |
Cleanup: remove selectionChanged logic from dive-list commands
Since all commands now fully reset the selection, there is no point
in keeping track of whether the selection changed on addition or
removal of dives. This can be done in the function that sets the
selection.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divelist.h')
-rw-r--r-- | desktop-widgets/command_divelist.h | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/desktop-widgets/command_divelist.h b/desktop-widgets/command_divelist.h index 152c7365b..20d031f54 100644 --- a/desktop-widgets/command_divelist.h +++ b/desktop-widgets/command_divelist.h @@ -49,17 +49,13 @@ struct DivesToTrip std::vector<OwningTripPtr> tripsToAdd; }; -// All divelist commands derive from a common base class, which has a flag -// for when then selection changed. In such a case, in the redo() and undo() -// methods a signal will be sent. The base-class implements redo() and undo(), -// which resets the flag and sends a signal. Derived classes implement the -// virtual methods redoit() and undoit() [Yes, the names could be more expressive]. -// Moreover, the class implements helper methods, which set the selectionChanged -// flag accordingly. +// All divelist commands derive from a common base class. It keeps track +// of dive site counts that may have changed. +// Derived classes implement the virtual methods redoit() and undoit() +// [Yes, the names could be more expressive]. class DiveListBase : public Base { protected: - // These are helper functions to add / remove dive from the C-core structures, - // which set the selectionChanged flag if the added / removed dive was selected. + // These are helper functions to add / remove dive from the C-core structures. DiveToAdd removeDive(struct dive *d, std::vector<OwningTripPtr> &tripsToAdd); dive *addDive(DiveToAdd &d); DivesAndTripsToAdd removeDives(DivesAndSitesToRemove &divesAndSitesToDelete); @@ -68,20 +64,11 @@ protected: // Register dive sites where counts changed so that we can signal the frontend later. void diveSiteCountChanged(struct dive_site *ds); - // Set the selection to a given state. Set the selectionChanged flag if anything changed. - void restoreSelection(const std::vector<dive *> &selection, dive *currentDive); - - // Commands set this flag if the selection changed on first execution. - // Only then, a new the divelist will be scanned again after the command. - // If this flag is set on first execution, a selectionChanged signal will - // be sent. - bool selectionChanged; - private: // Keep track of dive sites where the number of dives changed std::vector<dive_site *> sitesCountChanged; - void initWork(); // reset selectionChanged flag - void finishWork(); // emit signals if selection or dive site counts changed + void initWork(); + void finishWork(); // update dive site counts void undo() override; void redo() override; virtual void redoit() = 0; |