annotate base/Command.cpp @ 1179:6b1af0f05f06 pluginscan

Make use of, and warn for, the plugin checker for all types of plugin. Haven't yet resolved the question of how to install and find it.
author Chris Cannam
date Thu, 14 Apr 2016 14:03:18 +0100
parents cc27f35aa75c
children 48e9f538e6e9
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@19 2
Chris@19 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@19 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@19 14 */
Chris@19 15
Chris@19 16 #include "Command.h"
Chris@423 17 #include <QCoreApplication>
Chris@19 18
Chris@19 19 MacroCommand::MacroCommand(QString name) :
Chris@19 20 m_name(name)
Chris@19 21 {
Chris@19 22 }
Chris@19 23
Chris@19 24 MacroCommand::~MacroCommand()
Chris@19 25 {
Chris@19 26 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 27 delete m_commands[i];
Chris@19 28 }
Chris@19 29 }
Chris@19 30
Chris@19 31 void
Chris@19 32 MacroCommand::addCommand(Command *command)
Chris@19 33 {
Chris@19 34 m_commands.push_back(command);
Chris@19 35 }
Chris@19 36
Chris@19 37 void
Chris@19 38 MacroCommand::deleteCommand(Command *command)
Chris@19 39 {
Chris@19 40 for (std::vector<Command *>::iterator i = m_commands.begin();
Chris@19 41 i != m_commands.end(); ++i) {
Chris@19 42
Chris@19 43 if (*i == command) {
Chris@19 44 m_commands.erase(i);
Chris@19 45 delete command;
Chris@19 46 return;
Chris@19 47 }
Chris@19 48 }
Chris@19 49 }
Chris@19 50
Chris@47 51 bool
Chris@47 52 MacroCommand::haveCommands() const
Chris@47 53 {
Chris@47 54 return !m_commands.empty();
Chris@47 55 }
Chris@47 56
Chris@19 57 void
Chris@19 58 MacroCommand::execute()
Chris@19 59 {
Chris@19 60 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 61 m_commands[i]->execute();
Chris@19 62 }
Chris@19 63 }
Chris@19 64
Chris@19 65 void
Chris@19 66 MacroCommand::unexecute()
Chris@19 67 {
Chris@19 68 for (size_t i = 0; i < m_commands.size(); ++i) {
Chris@19 69 m_commands[m_commands.size() - i - 1]->unexecute();
Chris@19 70 }
Chris@19 71 }
Chris@19 72
Chris@47 73 QString
Chris@47 74 MacroCommand::getName() const
Chris@47 75 {
Chris@47 76 return m_name;
Chris@47 77 }
Chris@47 78
Chris@47 79 void
Chris@47 80 MacroCommand::setName(QString name)
Chris@47 81 {
Chris@47 82 m_name = name;
Chris@47 83 }
Chris@47 84
Chris@423 85 BundleCommand::BundleCommand(QString name) :
Chris@423 86 MacroCommand(name)
Chris@423 87 {
Chris@423 88 }
Chris@423 89
Chris@423 90 BundleCommand::~BundleCommand()
Chris@423 91 {
Chris@423 92 }
Chris@423 93
Chris@423 94 QString
Chris@423 95 BundleCommand::getName() const
Chris@423 96 {
Chris@423 97 if (m_commands.size() == 1) return m_name;
Chris@1038 98 return tr("%1 (%n change(s))", "", int(m_commands.size())).arg(m_name);
Chris@423 99 }
Chris@423 100