From d057af43b4365bbe790923fc6aca43c2ceccb8e6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 21 May 2022 21:30:57 +0200 Subject: [PATCH] undo: pass divecomputer number to EditProfile command Don't access the global variable dc_number, which might not make sense on mobile. Signed-off-by: Berthold Stoeger --- commands/command.cpp | 4 ++-- commands/command.h | 2 +- commands/command_edit.cpp | 4 ++-- commands/command_edit.h | 2 +- desktop-widgets/profilewidget.cpp | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/command.cpp b/commands/command.cpp index a22022f31..589bb9599 100644 --- a/commands/command.cpp +++ b/commands/command.cpp @@ -277,9 +277,9 @@ void replanDive(dive *d) execute(new ReplanDive(d)); } -void editProfile(const dive *d, EditProfileType type, int count) +void editProfile(const dive *d, int dcNr, EditProfileType type, int count) { - execute(new EditProfile(d, type, count)); + execute(new EditProfile(d, dcNr, type, count)); } int addWeight(bool currentDiveOnly) diff --git a/commands/command.h b/commands/command.h index 3342f9542..e7e4449c0 100644 --- a/commands/command.h +++ b/commands/command.h @@ -102,7 +102,7 @@ enum class EditProfileType { MOVE, }; void replanDive(dive *d); // dive computer(s) and cylinder(s) of first argument will be consumed! -void editProfile(const dive *d, EditProfileType type, int count); +void editProfile(const dive *d, int dcNr, EditProfileType type, int count); int addWeight(bool currentDiveOnly); int removeWeight(int index, bool currentDiveOnly); int editWeight(int index, weightsystem_t ws, bool currentDiveOnly); diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index 6e198fb44..c98cbfa99 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -882,8 +882,8 @@ QString editProfileTypeToString(EditProfileType type, int count) } } -EditProfile::EditProfile(const dive *source, EditProfileType type, int count) : d(current_dive), - dcNr(dc_number), +EditProfile::EditProfile(const dive *source, int dcNr, EditProfileType type, int count) : d(current_dive), + dcNr(dcNr), maxdepth({0}), meandepth({0}), dcmaxdepth({0}), diff --git a/commands/command_edit.h b/commands/command_edit.h index 417e994a0..529313037 100644 --- a/commands/command_edit.h +++ b/commands/command_edit.h @@ -352,7 +352,7 @@ class EditProfile : public Base { struct divecomputer dc; public: // Note: source must be clean (i.e. fixup_dive must have been called on it). - EditProfile(const dive *source, EditProfileType type, int count); + EditProfile(const dive *source, int dcNr, EditProfileType type, int count); ~EditProfile(); private: void undo() override; diff --git a/desktop-widgets/profilewidget.cpp b/desktop-widgets/profilewidget.cpp index 2540abd86..cb645310e 100644 --- a/desktop-widgets/profilewidget.cpp +++ b/desktop-widgets/profilewidget.cpp @@ -297,7 +297,7 @@ void ProfileWidget::stopAdded() return; calcDepth(*editedDive, editedDc); Setter s(placingCommand, true); - Command::editProfile(editedDive.get(), Command::EditProfileType::ADD, 0); + Command::editProfile(editedDive.get(), editedDc, Command::EditProfileType::ADD, 0); } void ProfileWidget::stopRemoved(int count) @@ -306,7 +306,7 @@ void ProfileWidget::stopRemoved(int count) return; calcDepth(*editedDive, editedDc); Setter s(placingCommand, true); - Command::editProfile(editedDive.get(), Command::EditProfileType::REMOVE, count); + Command::editProfile(editedDive.get(), editedDc, Command::EditProfileType::REMOVE, count); } void ProfileWidget::stopMoved(int count) @@ -315,5 +315,5 @@ void ProfileWidget::stopMoved(int count) return; calcDepth(*editedDive, editedDc); Setter s(placingCommand, true); - Command::editProfile(editedDive.get(), Command::EditProfileType::MOVE, count); + Command::editProfile(editedDive.get(), editedDc, Command::EditProfileType::MOVE, count); }