File: undo_delete_datum.h

package info (click to toggle)
antimony 0.9.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,476 kB
  • sloc: cpp: 42,596; ansic: 28,661; python: 1,093; yacc: 128; lex: 114; sh: 90; makefile: 10
file content (44 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <QJsonObject>

#include "undo/undo_command.h"

class UndoDeleteMulti;
class GraphNode;

class UndoDeleteDatum : public UndoCommand
{
public:
    /*
     *  UndoDeleteDatum constructor can only be called with a parent
     *  UndoDeleteMulti object, as deleting datums needs to be done
     *  along-side deleting their links.
     */
    UndoDeleteDatum(Datum* d, UndoDeleteMulti* parent);

    /*
     *  Actual commands to execute undo and redo
     */
    void redo() override;
    void undo() override;

    /*
     *  Node and graph pointer swap
     */
    void swapPointer(Datum* a, Datum* b) const override;
    void swapPointer(Node* a, Node* b) const override;

protected:
    /*
     *  Protected constructor used in UndoAddDatum subclass
     */
    UndoDeleteDatum(Datum* d);

    /*  Pointer to the target datum and its parent node */
    mutable Datum* d;
    mutable GraphNode* n;

    /*  This object stores the serialized datum  */
    QJsonObject data;
};