Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
undo.h
Go to the documentation of this file.
1 
8 #ifndef UNDO_H_
9 #define UNDO_H_
10 
11 class CAUndoCommand;
12 class CADocument;
13 
14 #include <QHash>
15 #include <QList>
16 
17 class CAUndo {
18 public:
19  CAUndo();
20  virtual ~CAUndo();
21 
22  bool canUndo( CADocument* );
23  bool canRedo( CADocument* );
24  void undo( CADocument* );
25  void redo( CADocument* );
26  inline bool containsUndoStack( CADocument *d ) { return _undoStack.contains(d); }
27  void createUndoStack( CADocument *d );
28  inline QList<CAUndoCommand*> *undoStack( CADocument* d ) { return _undoStack[d]; }
29  inline int& undoIndex( CADocument* d ) { return _undoIndex[undoStack(d)]; }
30  inline void removeUndoStack( CADocument *d ) { _undoStack.remove(d); }
31  void deleteUndoStack( CADocument *doc );
32  void createUndoCommand( CADocument *d, QString text );
33  void pushUndoCommand();
38  QList<CADocument*> getAllDocuments( CADocument *d );
39 private:
40  void clearUndoCommand();
41  CAUndoCommand *_undoCommand; // current undo command created to be put on the undo stack
42 
43  QHash< CADocument*, QList<CAUndoCommand*>* > _undoStack;
44  QHash< QList<CAUndoCommand*>*, int > _undoIndex;
45 };
46 
47 #endif /* UNDO_H_ */