mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
8ce4e10ccb
commit
0212b1b9f7
4 changed files with 63 additions and 20 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "command_base.h"
|
||||
#include "core/qthelper.h" // for updateWindowTitle()
|
||||
#include "core/subsurface-qt/divelistnotifier.h"
|
||||
#include <QVector>
|
||||
|
||||
namespace Command {
|
||||
|
||||
|
@ -49,6 +50,37 @@ QAction *redoAction(QObject *parent)
|
|||
return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo"));
|
||||
}
|
||||
|
||||
QString diveNumberOrDate(struct dive *d)
|
||||
{
|
||||
if (d->number != 0)
|
||||
return QStringLiteral("#%1").arg(d->number);
|
||||
else
|
||||
return QStringLiteral("@%1").arg(get_short_dive_date_string(d->when));
|
||||
}
|
||||
|
||||
QString getListOfDives(const std::vector<struct dive*> &dives)
|
||||
{
|
||||
QString listOfDives;
|
||||
if ((int)dives.size() == dive_table.nr)
|
||||
return Base::tr("all dives");
|
||||
int i = 0;
|
||||
for (dive *d: dives) {
|
||||
// we show a maximum of five dive numbers, or 4 plus ellipsis
|
||||
if (++i == 4 && dives.size() >= 5)
|
||||
return listOfDives + "...";
|
||||
listOfDives += diveNumberOrDate(d) + ", ";
|
||||
}
|
||||
if (!listOfDives.isEmpty())
|
||||
listOfDives.truncate(listOfDives.length() - 2);
|
||||
return listOfDives;
|
||||
}
|
||||
|
||||
QString getListOfDives(QVector<struct dive *> dives)
|
||||
{
|
||||
return getListOfDives(std::vector<struct dive *>(dives.begin(), dives.end()));
|
||||
}
|
||||
|
||||
|
||||
// return a string that can be used for the commit message and should list the changes that
|
||||
// were made to the dive list
|
||||
QString changesMade()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue