diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-03-05 09:00:00 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-10 09:25:57 -0700 |
commit | 0212b1b9f7734c2ee4edaf7e27a2c25601b5c4bc (patch) | |
tree | 6c3120611aa8b41948b6a96cc0f67d7cfd07b23d /commands/command_edit.cpp | |
parent | 8ce4e10ccb98558886ef4ead4554f44345acd603 (diff) | |
download | subsurface-0212b1b9f7734c2ee4edaf7e27a2c25601b5c4bc.tar.gz |
undo infrastructure: improve undo command texts
For many of the commands it is fairly easy to add information that makes
it easier to figure out what actually happened. That's especially true
for commands operating on dives. Trip and dive site edits haven't been
given these more elaborate undo texts (yet).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'commands/command_edit.cpp')
-rw-r--r-- | commands/command_edit.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index e08f678e7..753c67891 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -91,9 +91,9 @@ bool EditBase<T>::workToBeDone() // Create a text for the menu entry. In the case of multiple dives add the number size_t num_dives = dives.size(); if (num_dives == 1) - setText(tr("Edit %1").arg(fieldName())); + setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); else if (num_dives > 0) - setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); + setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); return num_dives > 0; } @@ -656,9 +656,9 @@ bool EditTagsBase::workToBeDone() // Create a text for the menu entry. In the case of multiple dives add the number size_t num_dives = dives.size(); if (num_dives == 1) - setText(tr("Edit %1").arg(fieldName())); + setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1").arg(fieldName())).arg(diveNumberOrDate(dives[0]))); else if (num_dives > 0) - setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); + setText(QStringLiteral("%1 [%2]").arg(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())).arg(getListOfDives(dives))); return num_dives != 0; } @@ -865,7 +865,7 @@ PasteDives::PasteDives(const dive *data, dive_components whatIn) : what(whatIn) for (dive *d: selection) dives.emplace_back(d, data, what); - setText(tr("Paste onto %n dive(s)", "", dives.size())); + setText(QStringLiteral("%1 [%2]").arg(tr("Paste onto %n dive(s)", "", dives.size())).arg(getListOfDives(selection))); } bool PasteDives::workToBeDone() @@ -941,7 +941,7 @@ ReplanDive::ReplanDive(dive *source, bool edit_profile) : d(current_dive), std::swap(source->cylinders, cylinders); std::swap(source->dc, dc); - setText(edit_profile ? tr("Replan dive") : tr("Edit profile")); + setText((edit_profile ? tr("Replan dive") : tr("Edit profile")) + diveNumberOrDate(d)); } ReplanDive::~ReplanDive() @@ -988,9 +988,9 @@ AddWeight::AddWeight(bool currentDiveOnly) : EditDivesBase(currentDiveOnly) { if (dives.size() == 1) - setText(tr("Add weight")); + setText(QStringLiteral("%1 [%2]").arg(tr("Add weight")).arg(diveNumberOrDate(dives[0]))); else - setText(tr("Add weight (%n dive(s))", "", dives.size())); + setText(QStringLiteral("%1 [%2]").arg(tr("Add weight (%n dive(s))", "", dives.size())).arg(getListOfDives(dives))); } bool AddWeight::workToBeDone() @@ -1071,10 +1071,11 @@ bool EditWeightBase::workToBeDone() RemoveWeight::RemoveWeight(int index, bool currentDiveOnly) : EditWeightBase(index, currentDiveOnly) { - if (dives.size() == 1) - setText(tr("Remove weight")); + size_t num_dives = dives.size(); + if (num_dives == 1) + setText(QStringLiteral("%1 [%2]").arg(tr("Remove weight")).arg(diveNumberOrDate(dives[0]))); else - setText(tr("Remove weight (%n dive(s))", "", dives.size())); + setText(QStringLiteral("%1 [%2]").arg(tr("Remove weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); } void RemoveWeight::undo() @@ -1100,10 +1101,11 @@ EditWeight::EditWeight(int index, weightsystem_t wsIn, bool currentDiveOnly) : if (dives.empty()) return; - if (dives.size() == 1) - setText(tr("Edit weight")); + size_t num_dives = dives.size(); + if (num_dives == 1) + setText(QStringLiteral("%1 [%2]").arg(tr("Edit weight")).arg(diveNumberOrDate(dives[0]))); else - setText(tr("Edit weight (%n dive(s))", "", dives.size())); + setText(QStringLiteral("%1 [%2]").arg(tr("Edit weight (%n dive(s))", "", num_dives)).arg(getListOfDives(dives))); // Try to untranslate the weightsystem name new_ws = clone_weightsystem(wsIn); @@ -1162,7 +1164,7 @@ EditDive::EditDive(dive *oldDiveIn, dive *newDiveIn, dive_site *createDs, dive_s if (!oldDive || ! newDive) return; - setText(tr("Edit dive")); + setText(tr("Edit dive [%1]").arg(diveNumberOrDate(oldDive))); // Calculate the fields that changed. // Note: Probably not needed, as on mobile we don't have that granularity. |