Mercurial > hg > svcore
annotate base/Command.cpp @ 47:bac8b14ab355
* Add menu for re-adding existing layers
* Fix layer tree window so that it at least approximates correct
* Add bundled operations in command history, for use with things like
multiple consecutive changes to a parameter value
* Disambiguate plugins that happen to have identical descriptions
* Add spectral centroid plugin (could use some parameters!)
* Some other fixes
author | Chris Cannam |
---|---|
date | Fri, 17 Mar 2006 17:38:28 +0000 |
parents | a7ed14263fe4 |
children | 39ae3dee27b9 |
rev | line source |
---|---|
Chris@19 | 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@19 | 2 |
Chris@19 | 3 /* |
Chris@19 | 4 A waveform viewer and audio annotation editor. |
Chris@19 | 5 Chris Cannam, Queen Mary University of London, 2005-2006 |
Chris@19 | 6 |
Chris@19 | 7 This is experimental software. Not for distribution. |
Chris@19 | 8 */ |
Chris@19 | 9 |
Chris@19 | 10 #include "Command.h" |
Chris@19 | 11 |
Chris@19 | 12 MacroCommand::MacroCommand(QString name) : |
Chris@19 | 13 m_name(name) |
Chris@19 | 14 { |
Chris@19 | 15 } |
Chris@19 | 16 |
Chris@19 | 17 MacroCommand::~MacroCommand() |
Chris@19 | 18 { |
Chris@19 | 19 for (size_t i = 0; i < m_commands.size(); ++i) { |
Chris@19 | 20 delete m_commands[i]; |
Chris@19 | 21 } |
Chris@19 | 22 } |
Chris@19 | 23 |
Chris@19 | 24 void |
Chris@19 | 25 MacroCommand::addCommand(Command *command) |
Chris@19 | 26 { |
Chris@19 | 27 m_commands.push_back(command); |
Chris@19 | 28 } |
Chris@19 | 29 |
Chris@19 | 30 void |
Chris@19 | 31 MacroCommand::deleteCommand(Command *command) |
Chris@19 | 32 { |
Chris@19 | 33 for (std::vector<Command *>::iterator i = m_commands.begin(); |
Chris@19 | 34 i != m_commands.end(); ++i) { |
Chris@19 | 35 |
Chris@19 | 36 if (*i == command) { |
Chris@19 | 37 m_commands.erase(i); |
Chris@19 | 38 delete command; |
Chris@19 | 39 return; |
Chris@19 | 40 } |
Chris@19 | 41 } |
Chris@19 | 42 } |
Chris@19 | 43 |
Chris@47 | 44 bool |
Chris@47 | 45 MacroCommand::haveCommands() const |
Chris@47 | 46 { |
Chris@47 | 47 return !m_commands.empty(); |
Chris@47 | 48 } |
Chris@47 | 49 |
Chris@19 | 50 void |
Chris@19 | 51 MacroCommand::execute() |
Chris@19 | 52 { |
Chris@19 | 53 for (size_t i = 0; i < m_commands.size(); ++i) { |
Chris@19 | 54 m_commands[i]->execute(); |
Chris@19 | 55 } |
Chris@19 | 56 } |
Chris@19 | 57 |
Chris@19 | 58 void |
Chris@19 | 59 MacroCommand::unexecute() |
Chris@19 | 60 { |
Chris@19 | 61 for (size_t i = 0; i < m_commands.size(); ++i) { |
Chris@19 | 62 m_commands[m_commands.size() - i - 1]->unexecute(); |
Chris@19 | 63 } |
Chris@19 | 64 } |
Chris@19 | 65 |
Chris@47 | 66 QString |
Chris@47 | 67 MacroCommand::getName() const |
Chris@47 | 68 { |
Chris@47 | 69 return m_name; |
Chris@47 | 70 } |
Chris@47 | 71 |
Chris@47 | 72 void |
Chris@47 | 73 MacroCommand::setName(QString name) |
Chris@47 | 74 { |
Chris@47 | 75 m_name = name; |
Chris@47 | 76 } |
Chris@47 | 77 |