comparison base/CommandHistory.cpp @ 46:5364a9d338a2

* Add Insert Instant function in main window * Ensure selections and window geometry are saved in session file * Add wait cursor on session file save * Various improvements to display of texts in pane (clearer readability) * Use commands for setting properties on layers and panes (still need to batch up multiple sets on the same property) * Fix failure of spectrogram to refresh when initial part became visible * Some fixes & paint optimisations in View &c * Make curve mode for time value layers work properly when resolution == 1 * Some vague improvements for time value layer vertical scale
author Chris Cannam
date Thu, 16 Mar 2006 18:46:00 +0000
parents 701404725897
children bac8b14ab355
comparison
equal deleted inserted replaced
45:b11edc8b8ea0 46:5364a9d338a2
31 CommandHistory *CommandHistory::m_instance = 0; 31 CommandHistory *CommandHistory::m_instance = 0;
32 32
33 CommandHistory::CommandHistory() : 33 CommandHistory::CommandHistory() :
34 m_undoLimit(50), 34 m_undoLimit(50),
35 m_redoLimit(50), 35 m_redoLimit(50),
36 m_menuLimit(15),
36 m_savedAt(0), 37 m_savedAt(0),
37 m_currentMacro(0), 38 m_currentMacro(0),
38 m_executeMacro(false) 39 m_executeMacro(false)
39 { 40 {
40 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); 41 m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this);
110 if (m_currentMacro) { 111 if (m_currentMacro) {
111 addToMacro(command); 112 addToMacro(command);
112 return; 113 return;
113 } 114 }
114 115
115 std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << std::endl; 116 std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl;
116 117
117 // We can't redo after adding a command 118 // We can't redo after adding a command
118 clearStack(m_redoStack); 119 clearStack(m_redoStack);
119 120
120 // can we reach savedAt? 121 // can we reach savedAt?
239 clipCommands(); 240 clipCommands();
240 } 241 }
241 } 242 }
242 243
243 void 244 void
245 CommandHistory::setMenuLimit(int limit)
246 {
247 m_menuLimit = limit;
248 updateActions();
249 }
250
251 void
244 CommandHistory::documentSaved() 252 CommandHistory::documentSaved()
245 { 253 {
246 m_savedAt = m_undoStack.size(); 254 m_savedAt = m_undoStack.size();
247 } 255 }
248 256
285 void 293 void
286 CommandHistory::clearStack(CommandStack &stack) 294 CommandHistory::clearStack(CommandStack &stack)
287 { 295 {
288 while (!stack.empty()) { 296 while (!stack.empty()) {
289 Command *command = stack.top(); 297 Command *command = stack.top();
290 std::cerr << "MVCH::clearStack: About to delete command: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl; 298 // Not safe to call getName() on a command about to be deleted
299 std::cerr << "MVCH::clearStack: About to delete command " << command << std::endl;
291 delete command; 300 delete command;
292 stack.pop(); 301 stack.pop();
293 } 302 }
294 } 303 }
295 304
351 menu->clear(); 360 menu->clear();
352 361
353 CommandStack tempStack; 362 CommandStack tempStack;
354 int j = 0; 363 int j = 0;
355 364
356 while (j < 10 && !stack.empty()) { 365 while (j < m_menuLimit && !stack.empty()) {
357 366
358 Command *command = stack.top(); 367 Command *command = stack.top();
359 tempStack.push(command); 368 tempStack.push(command);
360 stack.pop(); 369 stack.pop();
361 370