libsaria: Sort the playlist when setting PL_SORT
Otherwise the flag seems to have no effect until new songs are added. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
d785b91c46
commit
9933b31353
|
@ -39,6 +39,7 @@ namespace libsaria
|
|||
void schedule_save();
|
||||
void rm_file();
|
||||
void notify_ui(notify_t, Track *, unsigned int);
|
||||
void notify_update_all();
|
||||
|
||||
void incr_iter();
|
||||
Track *picked_next();
|
||||
|
@ -48,6 +49,7 @@ namespace libsaria
|
|||
void insert_sorted(Track *);
|
||||
void do_remove_tracks(list<Track *> &);
|
||||
unsigned int remove_track_it(list<Track *>::iterator &it, unsigned int);
|
||||
void do_sort();
|
||||
|
||||
protected:
|
||||
string name;
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace libsaria
|
|||
plist.push_front(track);
|
||||
|
||||
if (get_sorted()) {
|
||||
plist.sort();
|
||||
plist.sort(compare_tracks);
|
||||
index = find_index(track);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace libsaria
|
|||
unsigned int index = plist.size() + 1;
|
||||
plist.push_back(track);
|
||||
if (get_sorted()) {
|
||||
plist.sort();
|
||||
plist.sort(compare_tracks);
|
||||
index = find_index(track);
|
||||
}
|
||||
add_track(track, index);
|
||||
|
@ -149,4 +149,9 @@ namespace libsaria
|
|||
}
|
||||
}
|
||||
|
||||
void Playlist::do_sort()
|
||||
{
|
||||
plist.sort(compare_tracks);
|
||||
}
|
||||
|
||||
}; /* namespace: libsaria */
|
||||
|
|
|
@ -51,7 +51,8 @@ void read_plist(ifstream &stream)
|
|||
sorted = true;
|
||||
}
|
||||
|
||||
println("playlist type: %u size: %u disabled: %d", type, size, disabled);
|
||||
println("playlist size: %u disabled: %d random: %d sorted: %d",
|
||||
size, disabled, random, sorted);
|
||||
|
||||
for (unsigned int i = 0; i < size; i++) {
|
||||
stream >> libid >> trackid;
|
||||
|
@ -65,6 +66,8 @@ void read_plist(ifstream &stream)
|
|||
flags |= PL_DISABLED;
|
||||
if (random)
|
||||
flags |= PL_RANDOM;
|
||||
if (sorted)
|
||||
flags |= PL_SORTED;
|
||||
libsaria::deck::new_playlist(tracks, flags, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ namespace libsaria
|
|||
void Playlist::set_sorted(bool sorted)
|
||||
{
|
||||
set_flag(sorted, PL_SORTED);
|
||||
do_sort();
|
||||
notify_update_all();
|
||||
notify(PLAYLIST_SORTED, this);
|
||||
}
|
||||
|
||||
|
@ -173,4 +175,15 @@ namespace libsaria
|
|||
notify(type, &data);
|
||||
}
|
||||
|
||||
void Playlist::notify_update_all()
|
||||
{
|
||||
list<Track *>::iterator it;
|
||||
unsigned int index = 0;
|
||||
|
||||
for (it = plist.begin(); it != plist.end(); it++) {
|
||||
notify_ui(PLAYLIST_UPDATE, *it, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue