libsaria: Remove tracks by index
Because otherwise removing a track will remove all duplicates, too. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
900cac7e45
commit
99757c47f9
|
@ -86,8 +86,8 @@ namespace libsaria
|
|||
PlaylistType get_type();
|
||||
|
||||
virtual void add_tracks(list<Track *> &) = 0;
|
||||
void remove_indices(list<unsigned int> &);
|
||||
void remove_tracks(list<Track *> &);
|
||||
void force_remove_tracks(list<Track *> &);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ namespace libsaria
|
|||
length -= (*it)->get_length();
|
||||
index.remove_track(*it);
|
||||
it = plist.erase(it);
|
||||
if (rm_index != 0)
|
||||
it--;
|
||||
RENDER( remove_index(rm_index) );
|
||||
data_state = DIRTY;
|
||||
}
|
||||
|
||||
void Playlist::do_remove_tracks(list<Track *> &tracks)
|
||||
void Playlist::remove_tracks(list<Track *> &tracks)
|
||||
{
|
||||
list<Track *>::iterator p_it, t_it;
|
||||
unsigned int index = 0;
|
||||
|
@ -42,7 +44,6 @@ namespace libsaria
|
|||
for (t_it = tracks.begin(); t_it != tracks.end(); t_it++) {
|
||||
if (*p_it == *t_it) {
|
||||
remove_track_it(p_it, index);
|
||||
p_it--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -55,16 +56,34 @@ namespace libsaria
|
|||
RENDER( modify_done() );
|
||||
}
|
||||
|
||||
void Playlist::force_remove_tracks(list<Track *> &tracks)
|
||||
void Playlist::remove_indices(list<unsigned int> &indices)
|
||||
{
|
||||
do_remove_tracks(tracks);
|
||||
}
|
||||
list<Track *>::iterator to_rm, tmp;
|
||||
list<unsigned int>::iterator it;
|
||||
unsigned int index, removed;
|
||||
|
||||
void Playlist::remove_tracks(list<Track *> &tracks)
|
||||
{
|
||||
if (is_static())
|
||||
return;
|
||||
do_remove_tracks(tracks);
|
||||
indices.sort();
|
||||
|
||||
if (indices.back() >= plist.size())
|
||||
return;
|
||||
|
||||
RENDER( modify_prepare() );
|
||||
|
||||
index = 0;
|
||||
removed = 0;
|
||||
to_rm = plist.begin();
|
||||
for (it = indices.begin(); it != indices.end(); it++) {
|
||||
for (unsigned int i = 0; i < (*it - index); i++)
|
||||
to_rm++;
|
||||
remove_track_it(to_rm, (*it) - removed);
|
||||
index = *it;
|
||||
removed++;
|
||||
}
|
||||
|
||||
schedule_save();
|
||||
RENDER( modify_done() );
|
||||
}
|
||||
|
||||
void Playlist::add_sorted(list<Track *> &tracks)
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace libsaria
|
|||
track_ptrs.push_back(&(*t_it));
|
||||
|
||||
for (it = playlist_deck.begin(); it != playlist_deck.end(); it++)
|
||||
(*it)->force_remove_tracks(track_ptrs);
|
||||
(*it)->remove_tracks(track_ptrs);
|
||||
}
|
||||
|
||||
void deck::set_pause_type(AutoPauseType type, unsigned int count)
|
||||
|
|
Loading…
Reference in New Issue