3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
12 using namespace Marklin;
15 Track *Selection::get_track() const
20 return *tracks.begin();
23 void Selection::clear()
26 signal_changed.emit();
29 void Selection::add_track(Track *t)
31 if(tracks.insert(t).second)
32 signal_changed.emit();
35 void Selection::remove_track(Track *t)
38 signal_changed.emit();
41 void Selection::toggle_track(Track *t)
46 signal_changed.emit();
49 void Selection::select_more()
51 set<Track *> new_tracks;
52 for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
54 const vector<Track *> &links = (*i)->get_links();
55 for(vector<Track *>::const_iterator j=links.begin(); j!=links.end(); ++j)
57 new_tracks.insert(*j);
61 for(set<Track *>::iterator i=new_tracks.begin(); i!=new_tracks.end(); ++i)
62 if(tracks.insert(*i).second)
66 signal_changed.emit();
69 void Selection::select_linked()
72 list<Track *> queue(tracks.begin(), tracks.end());
75 Track *track = queue.front();
76 queue.erase(queue.begin());
78 const vector<Track *> &links = track->get_links();
79 for(vector<Track *>::const_iterator j=links.begin(); j!=links.end(); ++j)
80 if(*j && tracks.insert(*j).second)
86 for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
88 const vector<Track *> &links = (*i)->get_links();
89 for(vector<Track *>::const_iterator j=links.begin(); j!=links.end(); ++j)
90 if(*j && tracks.insert(*j).second)
95 signal_changed.emit();