File: undo_command.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-- 1,104 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 <QUndoCommand>

class UndoStack;

class Node;
class Datum;
class Graph;

class UndoCommand : public QUndoCommand
{
public:
    UndoCommand(QUndoCommand* parent=NULL);

    /*
     *  Sets the internal 'stack' pointer for this command
     *  and recursively for child commands
     */
    void setStack(UndoStack* s) { setStack(s, this); }

    /*
     *  Functions to be overloaded by derived classes
     */
    virtual void swapPointer(Node*, Node*) const {}
    virtual void swapPointer(Datum*, Datum*) const {}
    virtual void swapPointer(Graph*, Graph*) const {}

protected:
    /*
     *  If the given command is an UndoCommand, set its stack pointer;
     *  recurse over all children in any case.
     */
    static void setStack(UndoStack* s, const QUndoCommand* cmd);

    /*
     *  Backwards pointer to parent stack
     *
     *  Used so that commands can ask the stack to rewrite pointers
     *  (e.g. when undoing Node deletion, any other commands in the stack
     *   that refer to that Node by pointer must be updated)
     */
    mutable UndoStack* stack;
};