| 1212 | */ |
| 1213 | |
| 1214 | void KUndo2QStack::beginMacro(const KUndo2MagicString &text) |
| 1215 | { |
| 1216 | KUndo2Command *cmd = new KUndo2Command(); |
| 1217 | cmd->setText(text); |
| 1218 | |
| 1219 | if (m_macro_stack.isEmpty()) { |
| 1220 | while (m_index < m_command_list.size()) |
| 1221 | delete m_command_list.takeLast(); |
| 1222 | if (m_clean_index > m_index) |
| 1223 | m_clean_index = -1; // we've deleted the clean state |
| 1224 | m_command_list.append(cmd); |
| 1225 | } else { |
| 1226 | m_macro_stack.last()->d->child_list.append(cmd); |
| 1227 | } |
| 1228 | m_macro_stack.append(cmd); |
| 1229 | |
| 1230 | if (m_macro_stack.count() == 1) { |
| 1231 | Q_EMIT canUndoChanged(false); |
| 1232 | Q_EMIT undoTextChanged(QString()); |
| 1233 | Q_EMIT canRedoChanged(false); |
| 1234 | Q_EMIT redoTextChanged(QString()); |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /*! |
| 1239 | Ends composition of a macro command. |