undo.h
00001
00002
00003
00004
00005
00006
00007 #ifndef UNDO_H
00008 #define UNDO_H
00009
00010 #include <qobject.h>
00011 #include <qptrstack.h>
00012 #include <qstring.h>
00013
00014 class Command
00015 {
00016 public:
00017 Command() {}
00018 virtual ~Command() {};
00019 virtual QString name() = 0;
00020 virtual void redo() = 0;
00021 virtual void undo() = 0;
00022
00023 };
00024
00032 class StackBase : public QObject
00033 {
00034 Q_OBJECT
00035
00036 public:
00037 StackBase() : QObject() {}
00038
00039 void push(Command *c);
00040 bool isEmpty();
00041 Command *top();
00042 void clear();
00043
00044 signals:
00045 void changed();
00046
00047 protected:
00051 Command *pop();
00052
00053 QPtrStack<Command> mCommandStack;
00054 };
00055
00056 class UndoStack : public StackBase
00057 {
00058 public:
00059 static UndoStack *instance();
00060 void undo();
00061
00062 protected:
00063 UndoStack();
00064 static UndoStack* instance_;
00065 };
00066
00067 class RedoStack : public StackBase
00068 {
00069 public:
00070 static RedoStack *instance();
00071 void redo();
00072
00073 protected:
00074 RedoStack();
00075 static RedoStack* instance_;
00076 };
00077
00078 #endif
This file is part of the documentation for kdelibs Version 3.1.4.