summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/command.cpp7
-rw-r--r--commands/command.h1
-rw-r--r--commands/command_edit.cpp8
-rw-r--r--commands/command_edit.h4
4 files changed, 16 insertions, 4 deletions
diff --git a/commands/command.cpp b/commands/command.cpp
index d04128b8a..47595674f 100644
--- a/commands/command.cpp
+++ b/commands/command.cpp
@@ -260,7 +260,12 @@ void pasteDives(const dive *d, dive_components what)
void replanDive(dive *d)
{
- execute(new ReplanDive(d));
+ execute(new ReplanDive(d, false));
+}
+
+void editProfile(dive *d)
+{
+ execute(new ReplanDive(d, true));
}
// Trip editing related commands
diff --git a/commands/command.h b/commands/command.h
index 1b7e65394..6446b32fd 100644
--- a/commands/command.h
+++ b/commands/command.h
@@ -80,6 +80,7 @@ int editBuddies(const QStringList &newList, bool currentDiveOnly);
int editDiveMaster(const QStringList &newList, bool currentDiveOnly);
void pasteDives(const dive *d, dive_components what);
void replanDive(dive *d); // dive computer(s) and cylinder(s) will be reset!
+void editProfile(dive *d); // dive computer(s) and cylinder(s) will be reset!
// 5) Trip editing commands
diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp
index 215f57899..7f4726a6b 100644
--- a/commands/command_edit.cpp
+++ b/commands/command_edit.cpp
@@ -887,7 +887,7 @@ void PasteDives::redo()
}
// ***** Paste *****
-ReplanDive::ReplanDive(dive *source) : d(current_dive),
+ReplanDive::ReplanDive(dive *source, bool edit_profile) : d(current_dive),
dc({ 0 }),
notes(nullptr)
{
@@ -895,6 +895,10 @@ ReplanDive::ReplanDive(dive *source) : d(current_dive),
if (!d)
return;
+ // Fix source. Things might be inconsistent after modifying the profile.
+ source->maxdepth.mm = source->dc.maxdepth.mm = 0;
+ fixup_dive(source);
+
when = source->when;
maxdepth = source->maxdepth;
meandepth = source->meandepth;
@@ -907,7 +911,7 @@ ReplanDive::ReplanDive(dive *source) : d(current_dive),
std::swap(source->cylinders, cylinders);
std::swap(source->dc, dc);
- setText(tr("Replan dive"));
+ setText(edit_profile ? tr("Replan dive") : tr("Edit profile"));
}
ReplanDive::~ReplanDive()
diff --git a/commands/command_edit.h b/commands/command_edit.h
index cd12eaa04..c3acf9d48 100644
--- a/commands/command_edit.h
+++ b/commands/command_edit.h
@@ -320,7 +320,9 @@ class ReplanDive : public Base {
duration_t duration;
int salinity;
public:
- ReplanDive(dive *source); // Dive computer(s) and cylinders(s) of the source dive will be reset!
+ // Dive computer(s) and cylinders(s) of the source dive will be reset!
+ // If edit_profile is true, the text will be changed from "replan dive" to "edit profile".
+ ReplanDive(dive *source, bool edit_profile);
~ReplanDive();
private:
void undo() override;