Chris@19: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@19: Chris@19: /* Chris@19: A waveform viewer and audio annotation editor. Chris@19: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@19: Chris@19: This is experimental software. Not for distribution. Chris@19: */ Chris@19: Chris@19: #include "Command.h" Chris@19: Chris@19: MacroCommand::MacroCommand(QString name) : Chris@19: m_name(name) Chris@19: { Chris@19: } Chris@19: Chris@19: MacroCommand::~MacroCommand() Chris@19: { Chris@19: for (size_t i = 0; i < m_commands.size(); ++i) { Chris@19: delete m_commands[i]; Chris@19: } Chris@19: } Chris@19: Chris@19: void Chris@19: MacroCommand::addCommand(Command *command) Chris@19: { Chris@19: m_commands.push_back(command); Chris@19: } Chris@19: Chris@19: void Chris@19: MacroCommand::deleteCommand(Command *command) Chris@19: { Chris@19: for (std::vector::iterator i = m_commands.begin(); Chris@19: i != m_commands.end(); ++i) { Chris@19: Chris@19: if (*i == command) { Chris@19: m_commands.erase(i); Chris@19: delete command; Chris@19: return; Chris@19: } Chris@19: } Chris@19: } Chris@19: Chris@19: void Chris@19: MacroCommand::execute() Chris@19: { Chris@19: for (size_t i = 0; i < m_commands.size(); ++i) { Chris@19: m_commands[i]->execute(); Chris@19: } Chris@19: } Chris@19: Chris@19: void Chris@19: MacroCommand::unexecute() Chris@19: { Chris@19: for (size_t i = 0; i < m_commands.size(); ++i) { Chris@19: m_commands[m_commands.size() - i - 1]->unexecute(); Chris@19: } Chris@19: } Chris@19: