comparison widgets/CommandHistory.cpp @ 502:73a58a4dfebd

* Add vestigial Activity Log
author Chris Cannam
date Tue, 24 Feb 2009 14:01:42 +0000
parents 80e279e4f9fe
children 133b378d8efe
comparison
equal deleted inserted replaced
501:08e1ccfe289c 502:73a58a4dfebd
45 m_menuLimit(15), 45 m_menuLimit(15),
46 m_savedAt(0), 46 m_savedAt(0),
47 m_currentCompound(0), 47 m_currentCompound(0),
48 m_executeCompound(false), 48 m_executeCompound(false),
49 m_currentBundle(0), 49 m_currentBundle(0),
50 m_bundling(false),
50 m_bundleTimer(0), 51 m_bundleTimer(0),
51 m_bundleTimeout(5000) 52 m_bundleTimeout(3000)
52 { 53 {
53 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); 54 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this);
54 m_undoAction->setShortcut(tr("Ctrl+Z")); 55 m_undoAction->setShortcut(tr("Ctrl+Z"));
55 m_undoAction->setStatusTip(tr("Undo the last editing operation")); 56 m_undoAction->setStatusTip(tr("Undo the last editing operation"));
56 connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); 57 connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo()));
176 177
177 // Emit even if we aren't executing the command, because 178 // Emit even if we aren't executing the command, because
178 // someone must have executed it for this to make any sense 179 // someone must have executed it for this to make any sense
179 emit commandExecuted(); 180 emit commandExecuted();
180 emit commandExecuted(command); 181 emit commandExecuted(command);
181 182 if (!m_bundling) emit activity(command->getName());
183
182 updateActions(); 184 updateActions();
183 } 185 }
184 186
185 void 187 void
186 CommandHistory::addToBundle(Command *command, bool execute) 188 CommandHistory::addToBundle(Command *command, bool execute)
207 #endif 209 #endif
208 210
209 // need to addCommand before setting m_currentBundle, as addCommand 211 // need to addCommand before setting m_currentBundle, as addCommand
210 // with bundle false will reset m_currentBundle to 0 212 // with bundle false will reset m_currentBundle to 0
211 MacroCommand *mc = new BundleCommand(command->getName()); 213 MacroCommand *mc = new BundleCommand(command->getName());
214 m_bundling = true;
212 addCommand(mc, false); 215 addCommand(mc, false);
216 m_bundling = false;
213 m_currentBundle = mc; 217 m_currentBundle = mc;
214 m_currentBundleName = command->getName(); 218 m_currentBundleName = command->getName();
215 } 219 }
216 220
217 #ifdef DEBUG_COMMAND_HISTORY 221 #ifdef DEBUG_COMMAND_HISTORY
241 { 245 {
242 #ifdef DEBUG_COMMAND_HISTORY 246 #ifdef DEBUG_COMMAND_HISTORY
243 std::cerr << "CommandHistory::closeBundle" << std::endl; 247 std::cerr << "CommandHistory::closeBundle" << std::endl;
244 #endif 248 #endif
245 249
250 if (m_currentBundle) emit activity(m_currentBundle->getName());
246 m_currentBundle = 0; 251 m_currentBundle = 0;
247 m_currentBundleName = ""; 252 m_currentBundleName = "";
248 } 253 }
249 254
250 void 255 void
332 337
333 Command *command = m_undoStack.top(); 338 Command *command = m_undoStack.top();
334 command->unexecute(); 339 command->unexecute();
335 emit commandExecuted(); 340 emit commandExecuted();
336 emit commandUnexecuted(command); 341 emit commandUnexecuted(command);
342 emit activity(tr("Undo %1").arg(command->getName()));
337 343
338 m_redoStack.push(command); 344 m_redoStack.push(command);
339 m_undoStack.pop(); 345 m_undoStack.pop();
340 346
341 clipCommands(); 347 clipCommands();
357 363
358 Command *command = m_redoStack.top(); 364 Command *command = m_redoStack.top();
359 command->execute(); 365 command->execute();
360 emit commandExecuted(); 366 emit commandExecuted();
361 emit commandExecuted(command); 367 emit commandExecuted(command);
368 emit activity(tr("Redo %1").arg(command->getName()));
362 369
363 m_undoStack.push(command); 370 m_undoStack.push(command);
364 m_redoStack.pop(); 371 m_redoStack.pop();
365 // no need to clip 372 // no need to clip
366 373