52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
|
|
#ifndef NTX_ICOMMAND_H
|
||
|
|
#define NTX_ICOMMAND_H
|
||
|
|
|
||
|
|
#include <ntxinode.h>
|
||
|
|
#include <memory>
|
||
|
|
|
||
|
|
namespace ntx
|
||
|
|
{
|
||
|
|
|
||
|
|
// Einfache Struct für Clipboard-Eintrag
|
||
|
|
struct NtxNodeEntry
|
||
|
|
{
|
||
|
|
NtxNodePtr clone; // Elternloser Deep-Clone
|
||
|
|
NtxNodeWeakPtr originalParent; // Schwache Referenz für Undo
|
||
|
|
size_t originalPosition; // Position im Original-Parent
|
||
|
|
};
|
||
|
|
|
||
|
|
using NtxNodeEntryList = std::vector<NtxNodeEntry>;
|
||
|
|
|
||
|
|
class NtxICommand
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
|
||
|
|
virtual ~NtxICommand() = default;
|
||
|
|
|
||
|
|
virtual bool execute() = 0;
|
||
|
|
virtual bool undo() = 0;
|
||
|
|
|
||
|
|
virtual bool canExecute() const = 0;
|
||
|
|
virtual bool canUndo() const;
|
||
|
|
|
||
|
|
virtual NtxString getDescription() const;
|
||
|
|
|
||
|
|
protected:
|
||
|
|
|
||
|
|
NtxICommand() = default;
|
||
|
|
NtxICommand(const NtxICommand&) = default;
|
||
|
|
NtxICommand& operator=(const NtxICommand&) = default;
|
||
|
|
|
||
|
|
void setDescription(const NtxString& description);
|
||
|
|
|
||
|
|
private:
|
||
|
|
|
||
|
|
NtxString m_description;
|
||
|
|
};
|
||
|
|
|
||
|
|
using NtxCommandPtr = std::shared_ptr<NtxICommand>;
|
||
|
|
using NtxCommandUPtr = std::unique_ptr<NtxICommand>;
|
||
|
|
|
||
|
|
} // namespace ntx
|
||
|
|
|
||
|
|
#endif // NTX_ICOMMAND_H
|