mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: better change message in git save
This rarely gets seen / looked at, but it can help make it easier to understand what a user was doing when trying to restore dives that were inadvertantly deleted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
cca21cf07f
commit
c88d22462d
1 changed files with 20 additions and 2 deletions
|
@ -86,11 +86,29 @@ QString getListOfDives(QVector<struct dive *> dives)
|
||||||
|
|
||||||
// return a string that can be used for the commit message and should list the changes that
|
// return a string that can be used for the commit message and should list the changes that
|
||||||
// were made to the dive list
|
// were made to the dive list
|
||||||
|
// keep in mind that the changes could have been a number of undo commands, so we might have
|
||||||
|
// to go backwards from the last one written; this isn't perfect as a user could undo a command
|
||||||
|
// and then do something else instead of redoing that undo - the undo information is then lost
|
||||||
|
// for the changelog -- but of course the git history will show what happened
|
||||||
QString changesMade()
|
QString changesMade()
|
||||||
{
|
{
|
||||||
|
static int nextToWrite = 0;
|
||||||
|
int curIdx = undoStack->index();
|
||||||
QString changeTexts;
|
QString changeTexts;
|
||||||
for (int i = 0; i < undoStack->index(); i++)
|
|
||||||
changeTexts += undoStack->text(i) + "\n";
|
if (curIdx > nextToWrite) {
|
||||||
|
for (int i = nextToWrite; i < curIdx; i++)
|
||||||
|
changeTexts += undoStack->text(i) + "\n";
|
||||||
|
} else if (curIdx < nextToWrite) { // we walked back undoing things
|
||||||
|
for (int i = nextToWrite - 1; i >= curIdx; i--)
|
||||||
|
changeTexts += "(undo) " + undoStack->text(i) + "\n";
|
||||||
|
} else if (curIdx > 0) {
|
||||||
|
// so this means we undid something (or more than one thing) and then did something else
|
||||||
|
// so we lost the information of what was undone - and how many things were changed;
|
||||||
|
// just show the last change
|
||||||
|
changeTexts += undoStack->text(curIdx - 1) + "\n";
|
||||||
|
}
|
||||||
|
nextToWrite = curIdx;
|
||||||
return changeTexts;
|
return changeTexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue