mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
41072cf48f
This is used by the mobile UI to get notifications when the undo text changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
62 lines
1 KiB
C++
62 lines
1 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "command_base.h"
|
|
#include "core/qthelper.h" // for updateWindowTitle()
|
|
#include "core/subsurface-qt/divelistnotifier.h"
|
|
|
|
namespace Command {
|
|
|
|
static QUndoStack undoStack;
|
|
|
|
// General commands
|
|
void init()
|
|
{
|
|
QObject::connect(&undoStack, &QUndoStack::cleanChanged, &updateWindowTitle);
|
|
}
|
|
|
|
void clear()
|
|
{
|
|
undoStack.clear();
|
|
}
|
|
|
|
void setClean()
|
|
{
|
|
undoStack.setClean();
|
|
}
|
|
|
|
bool isClean()
|
|
{
|
|
return undoStack.isClean();
|
|
}
|
|
|
|
// this can be used to get access to the signals emitted by the QUndoStack
|
|
QUndoStack *getUndoStack()
|
|
{
|
|
return &undoStack;
|
|
}
|
|
|
|
QAction *undoAction(QObject *parent)
|
|
{
|
|
return undoStack.createUndoAction(parent, QCoreApplication::translate("Command", "&Undo"));
|
|
}
|
|
|
|
QAction *redoAction(QObject *parent)
|
|
{
|
|
return undoStack.createRedoAction(parent, QCoreApplication::translate("Command", "&Redo"));
|
|
}
|
|
|
|
bool execute(Base *cmd)
|
|
{
|
|
if (cmd->workToBeDone()) {
|
|
undoStack.push(cmd);
|
|
emit diveListNotifier.commandExecuted();
|
|
return true;
|
|
} else {
|
|
delete cmd;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} // namespace Command
|
|
|
|
|