mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
undo: add flag that indicates whether a command has been placed
In multiple places we have the problem that when an undo command is executed, the corresponding value-changed signals are emitted, which in turn updates the UI. This can have nasty UI effects, such as the cursor position in the notes field being reset. To avoid this, add a flag that indicates whether a newly placed command is currently executed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
04c5ab0e36
commit
1b8f3a06ec
2 changed files with 9 additions and 0 deletions
|
@ -26,6 +26,7 @@ bool isClean(); // Any changes need to be saved?
|
||||||
QAction *undoAction(QObject *parent); // Create an undo action.
|
QAction *undoAction(QObject *parent); // Create an undo action.
|
||||||
QAction *redoAction(QObject *parent); // Create an redo 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
|
QString changesMade(); // return a string with the texts from all commands on the undo stack -> for commit message
|
||||||
|
bool placingCommand(); // Currently executing a new command -> might not have to update the field the user just edited.
|
||||||
|
|
||||||
// 2) Dive-list related commands
|
// 2) Dive-list related commands
|
||||||
|
|
||||||
|
|
|
@ -91,10 +91,13 @@ QString changesMade()
|
||||||
return changeTexts;
|
return changeTexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool executingCommand = false;
|
||||||
bool execute(Base *cmd)
|
bool execute(Base *cmd)
|
||||||
{
|
{
|
||||||
if (cmd->workToBeDone()) {
|
if (cmd->workToBeDone()) {
|
||||||
|
executingCommand = true;
|
||||||
undoStack.push(cmd);
|
undoStack.push(cmd);
|
||||||
|
executingCommand = false;
|
||||||
emit diveListNotifier.commandExecuted();
|
emit diveListNotifier.commandExecuted();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -103,6 +106,11 @@ bool execute(Base *cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool placingCommand()
|
||||||
|
{
|
||||||
|
return executingCommand;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Command
|
} // namespace Command
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue