Mercurial > hg > svgui
diff widgets/CommandHistory.cpp @ 377:0bcb449d15f4
* Fix #1628781 changes to layer visibility and mute should use a command
* Also use a command for changes to layer playback pan, gain, plugin settings
* Refactor PlayParameterRepository to remove dependency on audioio from base
* Fix failure to save play parameters for main model in session file
author | Chris Cannam |
---|---|
date | Thu, 13 Mar 2008 14:06:03 +0000 |
parents | e1a9e478b7f2 |
children | 2c59b0cd176b |
line wrap: on
line diff
--- a/widgets/CommandHistory.cpp Wed Mar 12 17:42:56 2008 +0000 +++ b/widgets/CommandHistory.cpp Thu Mar 13 14:06:03 2008 +0000 @@ -35,6 +35,8 @@ #include <iostream> +//#define DEBUG_COMMAND_HISTORY 1 + CommandHistory *CommandHistory::m_instance = 0; CommandHistory::CommandHistory() : @@ -95,7 +97,9 @@ void CommandHistory::clear() { -// std::cerr << "CommandHistory::clear()" << std::endl; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::clear()" << std::endl; +#endif closeBundle(); m_savedAt = -1; clearStack(m_undoStack); @@ -147,10 +151,14 @@ closeBundle(); } -// std::cerr << "CommandHistory::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl; + if (!m_redoStack.empty()) { + std::cerr << "CommandHistory::clearing redo stack" << std::endl; + } +#endif // We can't redo after adding a command -// std::cerr << "CommandHistory::clearing redo stack" << std::endl; clearStack(m_redoStack); // can we reach savedAt? @@ -176,6 +184,11 @@ { if (m_currentBundle) { if (!command || (command->getName() != m_currentBundleName)) { +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::addToBundle: " + << command->getName().toStdString() + << ": closing current bundle" << std::endl; +#endif closeBundle(); } } @@ -183,6 +196,13 @@ if (!command) return; if (!m_currentBundle) { + +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::addToBundle: " + << command->getName().toStdString() + << ": creating new bundle" << std::endl; +#endif + // need to addCommand before setting m_currentBundle, as addCommand // with bundle false will reset m_currentBundle to 0 MacroCommand *mc = new MacroCommand(command->getName()); @@ -191,9 +211,22 @@ m_currentBundleName = command->getName(); } +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::addToBundle: " + << command->getName().toStdString() + << ": adding to bundle" << std::endl; +#endif + if (execute) command->execute(); m_currentBundle->addCommand(command); + // Emit even if we aren't executing the command, because + // someone must have executed it for this to make any sense + emit commandExecuted(); + emit commandExecuted(command); + + updateActions(); + delete m_bundleTimer; m_bundleTimer = new QTimer(this); connect(m_bundleTimer, SIGNAL(timeout()), this, SLOT(bundleTimerTimeout())); @@ -203,6 +236,10 @@ void CommandHistory::closeBundle() { +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::closeBundle" << std::endl; +#endif + m_currentBundle = 0; m_currentBundleName = ""; } @@ -210,13 +247,19 @@ void CommandHistory::bundleTimerTimeout() { +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::bundleTimerTimeout: bundle is " << m_currentBundle << std::endl; +#endif + closeBundle(); } void CommandHistory::addToCompound(Command *command, bool execute) { -// std::cerr << "CommandHistory::addToCompound: " << command->getName().toLocal8Bit().data() << std::endl; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::addToCompound: " << command->getName().toLocal8Bit().data() << std::endl; +#endif if (!m_currentCompound) { std::cerr << "CommandHistory::addToCompound: ERROR: no compound operation in progress!" << std::endl; return; @@ -278,6 +321,10 @@ { if (m_undoStack.empty()) return; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::undo()" << std::endl; +#endif + closeBundle(); Command *command = m_undoStack.top(); @@ -299,6 +346,10 @@ { if (m_redoStack.empty()) return; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::redo()" << std::endl; +#endif + closeBundle(); Command *command = m_redoStack.top(); @@ -374,8 +425,10 @@ CommandStack tempStack; for (i = 0; i < limit; ++i) { -// Command *command = stack.top(); -// std::cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl; +#ifdef DEBUG_COMMAND_HISTORY + Command *command = stack.top(); + std::cerr << "CommandHistory::clipStack: Saving recent command: " << command->getName().toLocal8Bit().data() << " at " << command << std::endl; +#endif tempStack.push(stack.top()); stack.pop(); } @@ -395,7 +448,9 @@ while (!stack.empty()) { Command *command = stack.top(); // Not safe to call getName() on a command about to be deleted -// std::cerr << "CommandHistory::clearStack: About to delete command " << command << std::endl; +#ifdef DEBUG_COMMAND_HISTORY + std::cerr << "CommandHistory::clearStack: About to delete command " << command << std::endl; +#endif delete command; stack.pop(); }