Logo Search packages:      
Sourcecode: rosegarden version File versions  Download package

void Rosegarden::CommandHistory::addCommand ( Command *  command,
bool  execute,
bool  bundle = false 

Add a command to the command history.

If execute is true, the command will be executed before being added. Otherwise it will be assumed to have been already executed -- a command should not be added to the history unless its work has actually been done somehow!

If a compound operation is in use (see startCompoundOperation below), the execute value passed to this method will override the execute status of the compound operation. In this way it's possible to have a compound operation mixing both to-execute and pre-executed commands.

If bundle is true, the command will be a candidate for bundling with any adjacent bundleable commands that have the same name, into a single compound command. This is useful for small commands that may be executed repeatedly altering the same data (e.g. type text, set a parameter) whose number and extent is not known in advance. The bundle parameter will be ignored if a compound operation is already in use.

Definition at line 139 of file CommandHistory.cpp.

References commandExecuted().

    if (!command) return;

    std::cerr << "CommandHistory::addCommand: " << command->getName().toLocal8Bit().data() << " at " << command << ": execute = " << execute << ", bundle = " << bundle << " (m_currentCompound = " << m_currentCompound << ", m_currentBundle = " << m_currentBundle << ")" << std::endl;

    if (m_currentCompound) {
      addToCompound(command, execute);

    if (bundle) {
      addToBundle(command, execute);
    } else if (m_currentBundle) {

    if (!m_redoStack.empty()) {
        std::cerr << "CommandHistory::clearing redo stack" << std::endl;

    // We can't redo after adding a command

    // can we reach savedAt?
    if ((int)m_undoStack.size() < m_savedAt) m_savedAt = -1; // nope

    if (execute) {

    // 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);


Generated by  Doxygen 1.6.0   Back to index