2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <sigc++/bind.h>
|
|
|
|
#include <pbd/error.h>
|
|
|
|
|
|
|
|
#include <ardour/playlist.h>
|
|
|
|
#include <ardour/redirect.h>
|
|
|
|
#include <ardour/route.h>
|
|
|
|
|
|
|
|
#include "route_redirect_selection.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
RouteRedirectSelection&
|
|
|
|
RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
|
|
|
|
{
|
|
|
|
if (&other != this) {
|
|
|
|
redirects = other.redirects;
|
|
|
|
routes = other.routes;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
|
|
|
|
{
|
|
|
|
return a.redirects == b.redirects &&
|
|
|
|
a.routes == b.routes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteRedirectSelection::clear ()
|
|
|
|
{
|
|
|
|
clear_redirects ();
|
|
|
|
clear_routes ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteRedirectSelection::clear_redirects ()
|
|
|
|
{
|
|
|
|
redirects.clear ();
|
|
|
|
RedirectsChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
RouteRedirectSelection::clear_routes ()
|
|
|
|
{
|
|
|
|
routes.clear ();
|
|
|
|
RoutesChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::add (boost::shared_ptr<Redirect> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (find (redirects.begin(), redirects.end(), r) == redirects.end()) {
|
|
|
|
redirects.push_back (r);
|
2006-07-27 12:52:14 -04:00
|
|
|
|
|
|
|
// XXX SHAREDPTR FIXME
|
|
|
|
// void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
|
|
|
|
// r->GoingAway.connect (mem_fun(*this, pmf));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
RedirectsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::add (const vector<boost::shared_ptr<Redirect> >& rlist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
for (vector<boost::shared_ptr<Redirect> >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
if (find (redirects.begin(), redirects.end(), *i) == redirects.end()) {
|
|
|
|
redirects.push_back (*i);
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
// XXX SHAREDPTR FIXME
|
|
|
|
|
|
|
|
//void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
|
|
|
|
// (*i)->GoingAway.connect (mem_fun(*this, pmf));
|
2005-09-25 14:42:24 -04:00
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
RedirectsChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::remove (boost::shared_ptr<Redirect> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
list<boost::shared_ptr<Redirect> >::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (redirects.begin(), redirects.end(), r)) != redirects.end()) {
|
|
|
|
redirects.erase (i);
|
|
|
|
RedirectsChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::set (boost::shared_ptr<Redirect> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_redirects ();
|
|
|
|
add (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::set (const vector<boost::shared_ptr<Redirect> >& rlist)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_redirects ();
|
|
|
|
add (rlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::add (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
if (find (routes.begin(), routes.end(), r) == routes.end()) {
|
|
|
|
routes.push_back (r);
|
|
|
|
|
2006-07-27 12:52:14 -04:00
|
|
|
// XXX SHAREDPTR FIXME
|
|
|
|
// void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
|
|
|
|
// r->GoingAway.connect (bind (mem_fun(*this, pmf), r));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
RoutesChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
list<boost::shared_ptr<Route> >::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
|
|
|
|
routes.erase (i);
|
|
|
|
RoutesChanged ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::set (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
clear_routes ();
|
|
|
|
add (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2006-07-27 12:52:14 -04:00
|
|
|
RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-27 12:52:14 -04:00
|
|
|
return find (routes.begin(), routes.end(), r) != routes.end();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
RouteRedirectSelection::empty ()
|
|
|
|
{
|
|
|
|
return redirects.empty () && routes.empty ();
|
|
|
|
}
|
|
|
|
|