diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-02-14 23:07:12 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 5436f9b8590e6022ce2dabefb23ffb037020784a (patch) | |
tree | 7de4df5ccae63f2bf57e95138d06a4f33680c362 /desktop-widgets/command_edit.h | |
parent | cddd5942f8accaa612d8e107b45c1bf3d47a5c95 (diff) | |
download | subsurface-5436f9b8590e6022ce2dabefb23ffb037020784a.tar.gz |
Undo: move dive-list logic into edit commands
The edit-commands were called with a list of selected dives and
the original value. Move the creation of the list and extraction
of the original value into the edit-commmands.
This removes the "current is last" rule and allows for more
flexibility.
Since the depth- and duration editing applies only to the current
dive and not all selected dives, add a parameter to the edit-commands
controlling whether only the current or all selected dives are edited.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.h')
-rw-r--r-- | desktop-widgets/command_edit.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/desktop-widgets/command_edit.h b/desktop-widgets/command_edit.h index 081ea11bb..4363cb9bd 100644 --- a/desktop-widgets/command_edit.h +++ b/desktop-widgets/command_edit.h @@ -33,12 +33,10 @@ protected: void redo() override; bool workToBeDone() override; - // Dives to be edited. For historical reasons, the *last* entry was - // the active dive when the user initialized the action. This dive - // will be made the current dive on redo / undo. - std::vector<dive *> dives; + std::vector<dive *> dives; // Dives to be edited. + struct dive *current; // On undo, we set the current dive at the time of the operation. public: - EditBase(const QVector<dive *> &dives, T newValue, T oldValue); + EditBase(T newValue, bool currentDiveOnly); protected: // Get and set functions to be overriden by sub-classes. @@ -139,7 +137,7 @@ class EditDiveSiteNew : public EditDiveSite { public: OwningDiveSitePtr diveSiteToAdd; struct dive_site *diveSiteToRemove; - EditDiveSiteNew(const QVector<dive *> &dives, const QString &newName, struct dive_site *oldValue); + EditDiveSiteNew(const QString &newName, bool currentDiveOnly); void undo() override; void redo() override; }; @@ -147,7 +145,7 @@ public: class EditMode : public EditBase<int> { int index; public: - EditMode(const QVector<dive *> &dives, int indexIn, int newValue, int oldValue); + EditMode(int indexIn, int newValue, bool currentDiveOnly); void set(struct dive *d, int i) const override; int data(struct dive *d) const override; QString fieldName() const override; @@ -164,10 +162,10 @@ class EditTagsBase : public Base { // the active dive when the user initialized the action. This dive // will be made the current dive on redo / undo. std::vector<dive *> dives; + struct dive *current; QStringList newList; // Temporary until initialized - struct dive *oldDive; // Temporary until initialized public: - EditTagsBase(const QVector<dive *> &dives, const QStringList &newList, struct dive *d); + EditTagsBase(const QStringList &newList, bool currentDiveOnly); protected: QStringList tagsToAdd; |