summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-05 08:56:17 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-10 09:25:57 -0700
commit626a149b7c6793dea6db1af23068b90205b65e2a (patch)
tree68483d6c9eb804faf0b1401a395a2af8207ff40e /commands
parent053356c49b34b5183ddb2e394bb916470115295b (diff)
downloadsubsurface-626a149b7c6793dea6db1af23068b90205b65e2a.tar.gz
undo infrastructure: collect the texts for the executed commands
This creates a single string with all the undo texts that are on the stack. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'commands')
-rw-r--r--commands/command.h1
-rw-r--r--commands/command_base.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/commands/command.h b/commands/command.h
index 00de1425a..f08249e0d 100644
--- a/commands/command.h
+++ b/commands/command.h
@@ -20,6 +20,7 @@ void setClean(); // Call after save - this marks a state where no changes need
bool isClean(); // Any changes need to be saved?
QAction *undoAction(QObject *parent); // Create an undo action.
QAction *redoAction(QObject *parent); // Create an redo action.
+QString changesMade(); // return a string with the texts from all commands on the undo stack -> for commit message
// 2) Dive-list related commands
diff --git a/commands/command_base.cpp b/commands/command_base.cpp
index 20147a541..1f924378b 100644
--- a/commands/command_base.cpp
+++ b/commands/command_base.cpp
@@ -45,6 +45,16 @@ QAction *redoAction(QObject *parent)
return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo"));
}
+// 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()
+{
+ QString changeTexts;
+ for (int i = 0; i < undoStack.index(); i++)
+ changeTexts += undoStack.text(i) + "\n";
+ return changeTexts;
+}
+
bool execute(Base *cmd)
{
if (cmd->workToBeDone()) {