summaryrefslogtreecommitdiffabout
path: root/kaddressbook/undo.cpp
Unidiff
Diffstat (limited to 'kaddressbook/undo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/undo.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/undo.cpp b/kaddressbook/undo.cpp
index 4442087..a6c1580 100644
--- a/kaddressbook/undo.cpp
+++ b/kaddressbook/undo.cpp
@@ -21,99 +21,99 @@
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "undo.h" 24#include "undo.h"
25 25
26/////////////////////////////// 26///////////////////////////////
27// StackBase 27// StackBase
28 28
29void StackBase::push(Command *c) 29void StackBase::push(Command *c)
30{ 30{
31 mCommandStack.push(c); 31 mCommandStack.push(c);
32 emit changed(); 32 emit changed();
33} 33}
34 34
35bool StackBase::isEmpty() 35bool StackBase::isEmpty()
36{ 36{
37 return mCommandStack.isEmpty(); 37 return mCommandStack.isEmpty();
38} 38}
39 39
40Command *StackBase::top() 40Command *StackBase::top()
41{ 41{
42 return mCommandStack.top(); 42 return mCommandStack.top();
43} 43}
44 44
45void StackBase::clear() 45void StackBase::clear()
46{ 46{
47 mCommandStack.clear(); 47 mCommandStack.clear();
48 emit changed(); 48 emit changed();
49} 49}
50 50
51Command *StackBase::pop() 51Command *StackBase::pop()
52{ 52{
53 Command *c = mCommandStack.pop(); 53 Command *c = mCommandStack.pop();
54 if (c) 54 if (c)
55 emit changed(); 55 emit changed();
56 56
57 return c; 57 return c;
58} 58}
59 59
60/////////////////////////////// 60///////////////////////////////
61// UndoStack 61// UndoStack
62 62
63UndoStack* UndoStack::instance_ = 0; 63UndoStack* UndoStack::instance_ = 0;
64 64
65UndoStack::UndoStack() 65UndoStack::UndoStack()
66 : StackBase() 66 : StackBase()
67{ 67{
68 // setAutoDelete( true ); 68 // setAutoDelete( true );
69} 69}
70 70
71UndoStack* UndoStack::instance() 71UndoStack* UndoStack::instance()
72{ 72{
73 if (!instance_) 73 if (!instance_)
74 instance_ = new UndoStack(); 74 instance_ = new UndoStack();
75 return instance_; 75 return instance_;
76} 76}
77 77
78void UndoStack::undo() 78void UndoStack::undo()
79{ 79{
80 if (isEmpty()) 80 if (isEmpty())
81 return; 81 return;
82 82
83 Command *command = pop(); 83 Command *command = pop();
84 command->undo(); 84 command->undo();
85 85
86 RedoStack::instance()->push( command ); 86 RedoStack::instance()->push( command );
87} 87}
88 88
89//////////////////// 89////////////////////
90// RedoStack 90// RedoStack
91 91
92RedoStack* RedoStack::instance_ = 0; 92RedoStack* RedoStack::instance_ = 0;
93 93
94RedoStack::RedoStack() 94RedoStack::RedoStack()
95{ 95{
96 mCommandStack.setAutoDelete( true ); 96 mCommandStack.setAutoDelete( true );
97} 97}
98 98
99RedoStack* RedoStack::instance() 99RedoStack* RedoStack::instance()
100{ 100{
101 if (!instance_) 101 if (!instance_)
102 instance_ = new RedoStack(); 102 instance_ = new RedoStack();
103 return instance_; 103 return instance_;
104} 104}
105 105
106void RedoStack::redo() 106void RedoStack::redo()
107{ 107{
108 Command *command; 108 Command *command;
109 if (isEmpty()) 109 if (isEmpty())
110 return; 110 return;
111 111
112 command = pop(); 112 command = pop();
113 command->redo(); 113 command->redo();
114 UndoStack::instance()->push( command ); 114 UndoStack::instance()->push( command );
115} 115}
116 116
117#ifndef KAB_EMBEDDED 117#ifndef KAB_EMBEDDED_
118#include "undo.moc" 118#include "moc_undo.cpp"
119#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED