00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "Command.h" 00017 00018 MacroCommand::MacroCommand(QString name) : 00019 m_name(name) 00020 { 00021 } 00022 00023 MacroCommand::~MacroCommand() 00024 { 00025 for (size_t i = 0; i < m_commands.size(); ++i) { 00026 delete m_commands[i]; 00027 } 00028 } 00029 00030 void 00031 MacroCommand::addCommand(Command *command) 00032 { 00033 m_commands.push_back(command); 00034 } 00035 00036 void 00037 MacroCommand::deleteCommand(Command *command) 00038 { 00039 for (std::vector<Command *>::iterator i = m_commands.begin(); 00040 i != m_commands.end(); ++i) { 00041 00042 if (*i == command) { 00043 m_commands.erase(i); 00044 delete command; 00045 return; 00046 } 00047 } 00048 } 00049 00050 bool 00051 MacroCommand::haveCommands() const 00052 { 00053 return !m_commands.empty(); 00054 } 00055 00056 void 00057 MacroCommand::execute() 00058 { 00059 for (size_t i = 0; i < m_commands.size(); ++i) { 00060 m_commands[i]->execute(); 00061 } 00062 } 00063 00064 void 00065 MacroCommand::unexecute() 00066 { 00067 for (size_t i = 0; i < m_commands.size(); ++i) { 00068 m_commands[m_commands.size() - i - 1]->unexecute(); 00069 } 00070 } 00071 00072 QString 00073 MacroCommand::getName() const 00074 { 00075 return m_name; 00076 } 00077 00078 void 00079 MacroCommand::setName(QString name) 00080 { 00081 m_name = name; 00082 } 00083
1.5.1