diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-25 07:53:40 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-25 13:59:04 -0700 |
commit | faebb539091ca5550bb6b60280d692c50d547bc0 (patch) | |
tree | 785284eedbc783bfd0f02318c05cabf48712e8ed /commands/command_device.h | |
parent | 572e2678a0c5e1a9c2a947e4a9a86f35cec125eb (diff) | |
download | subsurface-faebb539091ca5550bb6b60280d692c50d547bc0.tar.gz |
undo: add device related undo commands
Add commands for deleting devices and editing device nicknames
to include the device-handling in the undo system.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands/command_device.h')
-rw-r--r-- | commands/command_device.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/commands/command_device.h b/commands/command_device.h new file mode 100644 index 000000000..c1cf1a240 --- /dev/null +++ b/commands/command_device.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-2.0 +// Note: this header file is used by the undo-machinery and should not be included elsewhere. + +#ifndef COMMAND_DEVICE_H +#define COMMAND_DEVICE_H + +#include "command_base.h" +#include "core/device.h" + +struct device; + +// We put everything in a namespace, so that we can shorten names without polluting the global namespace +namespace Command { + +class RemoveDevice final : public Base { +public: + RemoveDevice(int index); +private: + // for undo + device dev; + + // for redo + int index; + + void undo() override; + void redo() override; + bool workToBeDone() override; +}; + +class EditDeviceNickname final : public Base { +public: + EditDeviceNickname(int index, const QString &nickname); +private: + // for redo and undo + int index; + std::string nickname; + + void undo() override; + void redo() override; + bool workToBeDone() override; +}; + +} // namespace Command +#endif |