Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@16
|
2
|
Chris@16
|
3 /*
|
Chris@52
|
4 Sonic Visualiser
|
Chris@52
|
5 An audio file viewer and annotation editor.
|
Chris@52
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@52
|
7 This file copyright 2006 Chris Cannam.
|
Chris@16
|
8
|
Chris@52
|
9 This program is free software; you can redistribute it and/or
|
Chris@52
|
10 modify it under the terms of the GNU General Public License as
|
Chris@52
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@52
|
12 License, or (at your option) any later version. See the file
|
Chris@52
|
13 COPYING included with this distribution for more information.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@1580
|
16 #ifndef SV_COMMAND_H
|
Chris@1580
|
17 #define SV_COMMAND_H
|
Chris@16
|
18
|
Chris@423
|
19 #include <QObject>
|
Chris@17
|
20 #include <QString>
|
Chris@17
|
21 #include <vector>
|
Chris@17
|
22
|
Chris@686
|
23 #include "Debug.h"
|
Chris@686
|
24
|
Chris@16
|
25 class Command
|
Chris@16
|
26 {
|
Chris@16
|
27 public:
|
Chris@17
|
28 virtual ~Command() { }
|
Chris@17
|
29
|
Chris@16
|
30 virtual void execute() = 0;
|
Chris@16
|
31 virtual void unexecute() = 0;
|
Chris@17
|
32 virtual QString getName() const = 0;
|
Chris@17
|
33 };
|
Chris@17
|
34
|
Chris@17
|
35 class MacroCommand : public Command
|
Chris@17
|
36 {
|
Chris@17
|
37 public:
|
Chris@17
|
38 MacroCommand(QString name);
|
Chris@17
|
39 virtual ~MacroCommand();
|
Chris@17
|
40
|
Chris@17
|
41 virtual void addCommand(Command *command);
|
Chris@17
|
42 virtual void deleteCommand(Command *command);
|
Chris@47
|
43 virtual bool haveCommands() const;
|
Chris@17
|
44
|
Chris@1580
|
45 void execute() override;
|
Chris@1580
|
46 void unexecute() override;
|
Chris@17
|
47
|
Chris@1580
|
48 QString getName() const override;
|
Chris@47
|
49 virtual void setName(QString name);
|
Chris@17
|
50
|
Chris@17
|
51 protected:
|
Chris@17
|
52 QString m_name;
|
Chris@17
|
53 std::vector<Command *> m_commands;
|
Chris@16
|
54 };
|
Chris@16
|
55
|
Chris@423
|
56 /**
|
Chris@423
|
57 * BundleCommand is a MacroCommand whose name includes a note of how
|
Chris@423
|
58 * many commands it contains. It is a QObject with Q_OBJECT macro so
|
Chris@423
|
59 * that it can do plural-sensitive translations.
|
Chris@423
|
60 */
|
Chris@423
|
61 class BundleCommand : public QObject, public MacroCommand
|
Chris@423
|
62 {
|
Chris@423
|
63 Q_OBJECT
|
Chris@423
|
64
|
Chris@423
|
65 public:
|
Chris@423
|
66 BundleCommand(QString name);
|
Chris@423
|
67 virtual ~BundleCommand();
|
Chris@423
|
68
|
Chris@1580
|
69 QString getName() const override;
|
Chris@423
|
70 };
|
Chris@423
|
71
|
Chris@16
|
72 #endif
|
Chris@16
|
73
|