Mercurial > hg > svcore
diff base/CommandHistory.cpp @ 44:701404725897
* Use commands for add/delete pane in main window
* Add compound command collection to command history (for add pane, import file
etc)
* Add hide/show pane and hidden pane list to PaneStack
* Various other fixes
author | Chris Cannam |
---|---|
date | Mon, 13 Mar 2006 17:55:19 +0000 |
parents | 2b6412c1e724 |
children | 5364a9d338a2 |
line wrap: on
line diff
--- a/base/CommandHistory.cpp Fri Mar 10 12:28:22 2006 +0000 +++ b/base/CommandHistory.cpp Mon Mar 13 17:55:19 2006 +0000 @@ -33,7 +33,9 @@ CommandHistory::CommandHistory() : m_undoLimit(50), m_redoLimit(50), - m_savedAt(0) + m_savedAt(0), + m_currentMacro(0), + m_executeMacro(false) { m_undoAction = new QAction(QIcon(":/icons/undo.png"), tr("&Undo"), this); m_undoAction->setShortcut(tr("Ctrl+Z")); @@ -105,6 +107,11 @@ { if (!command) return; + if (m_currentMacro) { + addToMacro(command); + return; + } + std::cerr << "MVCH::addCommand: " << command->getName().toLocal8Bit().data() << std::endl; // We can't redo after adding a command @@ -129,6 +136,43 @@ } void +CommandHistory::addToMacro(Command *command) +{ + std::cerr << "MVCH::addToMacro: " << command->getName().toLocal8Bit().data() << std::endl; + + if (m_executeMacro) command->execute(); + m_currentMacro->addCommand(command); +} + +void +CommandHistory::startCompoundOperation(QString name, bool execute) +{ + if (m_currentMacro) { + std::cerr << "MVCH::startCompoundOperation: ERROR: compound operation already in progress!" << std::endl; + std::cerr << "(name is " << m_currentMacro->getName().toLocal8Bit().data() << ")" << std::endl; + } + + m_currentMacro = new MacroCommand(name); + m_executeMacro = execute; +} + +void +CommandHistory::endCompoundOperation() +{ + if (!m_currentMacro) { + std::cerr << "MVCH::endCompoundOperation: ERROR: no compound operation in progress!" << std::endl; + } + + Command *toAdd = m_currentMacro; + m_currentMacro = 0; + + // We don't execute the macro command here, because we have been + // executing the individual commands as we went along if + // m_executeMacro was true. + addCommand(toAdd, false); +} + +void CommandHistory::addExecutedCommand(Command *command) { addCommand(command, false);