playqueue: Add flags to disable sorting

The history playqueue should never change sort order, so use this flag
to prevent user changes.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-26 14:49:07 -05:00 committed by Anna Schumaker
parent 6a227df41b
commit 2962d792d7
3 changed files with 8 additions and 1 deletions

View File

@ -13,7 +13,8 @@ enum playqueue_flags {
PQ_ENABLED = (1 << 0),
PQ_RANDOM = (1 << 1),
PQ_REPEAT = (1 << 2),
PQ_DISABLE_CHANGED_SIZE = (1 << 3),
PQ_NEVER_SORT = (1 << 3),
PQ_DISABLE_CHANGED_SIZE = (1 << 31),
};
enum sort_t {

View File

@ -103,6 +103,7 @@ void audio :: init(int *argc, char ***argv)
GstBus *bus;
o_recently_played.set_flag(PQ_REPEAT);
o_recently_played.set_flag(PQ_NEVER_SORT);
o_recently_played.set_flag(PQ_DISABLE_CHANGED_SIZE);
gst_init(argc, argv);

View File

@ -283,6 +283,9 @@ void Playqueue :: _add_sort(sort_t field)
void Playqueue :: add_sort(sort_t field)
{
if (flags & PQ_NEVER_SORT)
return;
_add_sort(field);
std::stable_sort(tracks.begin(), tracks.end(), SortTracks(sort_order));
@ -293,6 +296,8 @@ void Playqueue :: add_sort(sort_t field)
void Playqueue :: reset_sort(sort_t field)
{
if (flags & PQ_NEVER_SORT)
return;
sort_order.clear();
add_sort(field);
}