diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-26 19:09:28 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-26 13:54:59 -0700 |
commit | f43b3f56b252c2403b072298d4dbd613f03c479f (patch) | |
tree | 6c9f5b6bcb453b715495ec0bdcc0c749ba49ce8b /core | |
parent | 2ad3696230e5bbd4f5a339121812d27e857c1789 (diff) | |
download | subsurface-f43b3f56b252c2403b072298d4dbd613f03c479f.tar.gz |
cleanup: remove Command::inCommand()
This was used by the divelist to check wether a selection change is
programmatical or user-initiated. However, since there is only one
entry point for programmatical selection changes, this is not needed
anymore. Remove it - this removes an inter-module dependency.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/subsurface-qt/divelistnotifier.h | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/core/subsurface-qt/divelistnotifier.h b/core/subsurface-qt/divelistnotifier.h index 63355fbcc..b5f8106d5 100644 --- a/core/subsurface-qt/divelistnotifier.h +++ b/core/subsurface-qt/divelistnotifier.h @@ -121,68 +121,12 @@ signals: // This is necessary, so that the user can't click on the "undo" button and undo // an unrelated command. void commandExecuted(); -public: - // Desktop uses the QTreeView class to present the list of dives. The layout - // of this class gives us a very fundamental problem, as we can not easily - // distinguish between user-initiated changes of the selection and changes - // that are due to actions of the Command-classes. To solve this problem, - // the frontend can use this function to query whether a dive list-modifying - // command is currently executed. If this function returns true, the - // frontend is supposed to not modify the selection. - bool inCommand() const; - - // The following class and function are used by divelist-modifying commands - // to signal that they are in-flight. If the returned object goes out of scope, - // the command-in-flight status is reset to its previous value. Thus, the - // function can be called recursively. - class InCommandMarker { - DiveListNotifier ¬ifier; - bool oldValue; - InCommandMarker(DiveListNotifier &); - friend DiveListNotifier; - public: - ~InCommandMarker(); - }; - - // Usage: - // void doWork() - // { - // auto marker = diveListNotifier.enterCommand(); - // ... do work ... - // } - InCommandMarker enterCommand(); -private: - friend InCommandMarker; - bool commandExecuting; }; // The DiveListNotifier class has only trivial state. // We can simply define it as a global object. extern DiveListNotifier diveListNotifier; -// InCommandMarker is so trivial that the functions can be inlined. -// TODO: perhaps move this into own header-file. -inline DiveListNotifier::InCommandMarker::InCommandMarker(DiveListNotifier ¬ifierIn) : notifier(notifierIn), - oldValue(notifier.commandExecuting) -{ - notifier.commandExecuting = true; -} - -inline DiveListNotifier::InCommandMarker::~InCommandMarker() -{ - notifier.commandExecuting = oldValue; -} - -inline bool DiveListNotifier::inCommand() const -{ - return commandExecuting; -} - -inline DiveListNotifier::InCommandMarker DiveListNotifier::enterCommand() -{ - return InCommandMarker(*this); -} - inline DiveField::DiveField(int flags) : nr((flags & NR) != 0), datetime((flags & DATETIME) != 0), |