mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
572e2678a0
commit
faebb53909
9 changed files with 140 additions and 1 deletions
44
commands/command_device.h
Normal file
44
commands/command_device.h
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue