-rw-r--r-- | kaddressbook/undo.cpp | 4 |
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 | |||
@@ -1,119 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> | 3 | Copyright (C) 1999 Don Sanders <sanders@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
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 | ||
29 | void StackBase::push(Command *c) | 29 | void StackBase::push(Command *c) |
30 | { | 30 | { |
31 | mCommandStack.push(c); | 31 | mCommandStack.push(c); |
32 | emit changed(); | 32 | emit changed(); |
33 | } | 33 | } |
34 | 34 | ||
35 | bool StackBase::isEmpty() | 35 | bool StackBase::isEmpty() |
36 | { | 36 | { |
37 | return mCommandStack.isEmpty(); | 37 | return mCommandStack.isEmpty(); |
38 | } | 38 | } |
39 | 39 | ||
40 | Command *StackBase::top() | 40 | Command *StackBase::top() |
41 | { | 41 | { |
42 | return mCommandStack.top(); | 42 | return mCommandStack.top(); |
43 | } | 43 | } |
44 | 44 | ||
45 | void StackBase::clear() | 45 | void StackBase::clear() |
46 | { | 46 | { |
47 | mCommandStack.clear(); | 47 | mCommandStack.clear(); |
48 | emit changed(); | 48 | emit changed(); |
49 | } | 49 | } |
50 | 50 | ||
51 | Command *StackBase::pop() | 51 | Command *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 | ||
63 | UndoStack* UndoStack::instance_ = 0; | 63 | UndoStack* UndoStack::instance_ = 0; |
64 | 64 | ||
65 | UndoStack::UndoStack() | 65 | UndoStack::UndoStack() |
66 | : StackBase() | 66 | : StackBase() |
67 | { | 67 | { |
68 | // setAutoDelete( true ); | 68 | // setAutoDelete( true ); |
69 | } | 69 | } |
70 | 70 | ||
71 | UndoStack* UndoStack::instance() | 71 | UndoStack* 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 | ||
78 | void UndoStack::undo() | 78 | void 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 | ||
92 | RedoStack* RedoStack::instance_ = 0; | 92 | RedoStack* RedoStack::instance_ = 0; |
93 | 93 | ||
94 | RedoStack::RedoStack() | 94 | RedoStack::RedoStack() |
95 | { | 95 | { |
96 | mCommandStack.setAutoDelete( true ); | 96 | mCommandStack.setAutoDelete( true ); |
97 | } | 97 | } |
98 | 98 | ||
99 | RedoStack* RedoStack::instance() | 99 | RedoStack* 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 | ||
106 | void RedoStack::redo() | 106 | void 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 |