Mercurial > hg > easaier-soundaccess
comparison base/Command.cpp @ 0:fc9323a41f5a
start base : Sonic Visualiser sv1-1.0rc1
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 09:08:14 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:fc9323a41f5a |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "Command.h" | |
17 | |
18 MacroCommand::MacroCommand(QString name) : | |
19 m_name(name) | |
20 { | |
21 } | |
22 | |
23 MacroCommand::~MacroCommand() | |
24 { | |
25 for (size_t i = 0; i < m_commands.size(); ++i) { | |
26 delete m_commands[i]; | |
27 } | |
28 } | |
29 | |
30 void | |
31 MacroCommand::addCommand(Command *command) | |
32 { | |
33 m_commands.push_back(command); | |
34 } | |
35 | |
36 void | |
37 MacroCommand::deleteCommand(Command *command) | |
38 { | |
39 for (std::vector<Command *>::iterator i = m_commands.begin(); | |
40 i != m_commands.end(); ++i) { | |
41 | |
42 if (*i == command) { | |
43 m_commands.erase(i); | |
44 delete command; | |
45 return; | |
46 } | |
47 } | |
48 } | |
49 | |
50 bool | |
51 MacroCommand::haveCommands() const | |
52 { | |
53 return !m_commands.empty(); | |
54 } | |
55 | |
56 void | |
57 MacroCommand::execute() | |
58 { | |
59 for (size_t i = 0; i < m_commands.size(); ++i) { | |
60 m_commands[i]->execute(); | |
61 } | |
62 } | |
63 | |
64 void | |
65 MacroCommand::unexecute() | |
66 { | |
67 for (size_t i = 0; i < m_commands.size(); ++i) { | |
68 m_commands[m_commands.size() - i - 1]->unexecute(); | |
69 } | |
70 } | |
71 | |
72 QString | |
73 MacroCommand::getName() const | |
74 { | |
75 return m_name; | |
76 } | |
77 | |
78 void | |
79 MacroCommand::setName(QString name) | |
80 { | |
81 m_name = name; | |
82 } | |
83 |