summaryrefslogtreecommitdiffstats
path: root/commands/command_divelist.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-05 09:00:00 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-10 09:25:57 -0700
commit0212b1b9f7734c2ee4edaf7e27a2c25601b5c4bc (patch)
tree6c3120611aa8b41948b6a96cc0f67d7cfd07b23d /commands/command_divelist.cpp
parent8ce4e10ccb98558886ef4ead4554f44345acd603 (diff)
downloadsubsurface-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_divelist.cpp')
-rw-r--r--commands/command_divelist.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp
index 28857c8fa..93689d44a 100644
--- a/commands/command_divelist.cpp
+++ b/commands/command_divelist.cpp
@@ -546,7 +546,7 @@ void ImportDives::undoit()
DeleteDive::DeleteDive(const QVector<struct dive*> &divesToDeleteIn)
{
divesToDelete.dives = std::vector<dive *>(divesToDeleteIn.begin(), divesToDeleteIn.end());
- setText(tr("delete %n dive(s)", "", divesToDelete.dives.size()));
+ setText(QStringLiteral("%1 [%2]").arg(tr("delete %n dive(s)", "", divesToDelete.dives.size())).arg(getListOfDives(divesToDelete.dives)));
}
bool DeleteDive::workToBeDone()
@@ -582,7 +582,7 @@ void DeleteDive::redoit()
ShiftTime::ShiftTime(std::vector<dive *> changedDives, int amount)
: diveList(changedDives), timeChanged(amount)
{
- setText(tr("shift time of %n dives", "", changedDives.size()));
+ setText(QStringLiteral("%1 [%2]").arg(tr("shift time of %n dives", "", changedDives.size())).arg(getListOfDives(changedDives)));
}
void ShiftTime::redoit()
@@ -626,7 +626,11 @@ void ShiftTime::undoit()
RenumberDives::RenumberDives(const QVector<QPair<dive *, int>> &divesToRenumberIn) : divesToRenumber(divesToRenumberIn)
{
- setText(tr("renumber %n dive(s)", "", divesToRenumber.count()));
+ std::vector<struct dive *> dives;
+ dives.reserve(divesToRenumber.length());
+ for (QPair<dive *, int>divePlusNumber: divesToRenumber)
+ dives.push_back(divePlusNumber.first);
+ setText(QStringLiteral("%1 [%2]").arg(tr("renumber %n dive(s)", "", divesToRenumber.count())).arg(getListOfDives(dives)));
}
void RenumberDives::undoit()
@@ -678,7 +682,7 @@ void TripBase::undoit()
RemoveDivesFromTrip::RemoveDivesFromTrip(const QVector<dive *> &divesToRemove)
{
- setText(tr("remove %n dive(s) from trip", "", divesToRemove.size()));
+ setText(QStringLiteral("%1 [%2]").arg(tr("remove %n dive(s) from trip", "", divesToRemove.size())).arg(getListOfDives(divesToRemove)));
divesToMove.divesToMove.reserve(divesToRemove.size());
for (dive *d: divesToRemove) {
// If a user manually removes a dive from a trip, don't autogroup this dive.
@@ -702,7 +706,7 @@ RemoveAutogenTrips::RemoveAutogenTrips()
AddDivesToTrip::AddDivesToTrip(const QVector<dive *> &divesToAddIn, dive_trip *trip)
{
- setText(tr("add %n dives to trip", "", divesToAddIn.size()));
+ setText(QStringLiteral("%1 [%2]").arg(tr("add %n dives to trip", "", divesToAddIn.size())).arg(getListOfDives(divesToAddIn)));
for (dive *d: divesToAddIn)
divesToMove.divesToMove.push_back( {d, trip} );
}