Refactored ParentTrack::remove_descendant_track
This commit is contained in:
parent
ed1f4abfea
commit
0689e0256c
3 changed files with 8 additions and 28 deletions
|
|
@ -51,21 +51,16 @@ ParentTrack::can_host_children() const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ParentTrack::remove_descendant_track(const boost::shared_ptr<Track> track)
|
ParentTrack::remove_descendant_track(
|
||||||
|
const boost::shared_ptr<Track> track)
|
||||||
{
|
{
|
||||||
REQUIRE(track);
|
REQUIRE(track);
|
||||||
|
|
||||||
BOOST_FOREACH(const boost::shared_ptr<Track> child_track, tracks)
|
boost::shared_ptr<ParentTrack> parent =
|
||||||
|
find_descendant_track_parent(track);
|
||||||
|
if(parent)
|
||||||
{
|
{
|
||||||
REQUIRE(child_track);
|
parent->tracks.remove(track);
|
||||||
|
|
||||||
if(track.get() == child_track.get())
|
|
||||||
{
|
|
||||||
tracks.remove(track);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(child_track->remove_descendant_track(track))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,6 @@ Track::can_host_children() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
Track::remove_descendant_track(const shared_ptr<Track> /*track*/)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
string
|
string
|
||||||
Track::print_branch()
|
Track::print_branch()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,6 @@ public:
|
||||||
**/
|
**/
|
||||||
virtual bool can_host_children() const;
|
virtual bool can_host_children() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to remove a given track from amongst the descendants of this
|
|
||||||
* track.
|
|
||||||
* @param The model track to try and remove.
|
|
||||||
* @return Returns true if the track was successfully removed.
|
|
||||||
**/
|
|
||||||
virtual bool remove_descendant_track(
|
|
||||||
const boost::shared_ptr<Track> track);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility function that attempts to find the parent of a track by
|
* A utility function that attempts to find the parent of a track by
|
||||||
* searching through the tree from this track downward.
|
* searching through the tree from this track downward.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue