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;

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

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

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

#ifdef DEBUG_COMMAND_HISTORY
    if (!m_redoStack.empty()) {
        std::cerr << "CommandHistory::clearing redo stack" << std::endl;
    }
#endif

    // We can't redo after adding a command
    clearStack(m_redoStack);

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

    m_undoStack.push(command);
    clipCommands();
    
    if (execute) {
      command->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);

    updateActions();
}


Generated by  Doxygen 1.6.0   Back to index