queue: Remove the add_front() function
This is best implemented in a derived class, since it's only used by the recently played queue. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
38ae4ba0f3
commit
74bf30bec5
|
@ -33,6 +33,7 @@ protected:
|
||||||
unsigned int _length;
|
unsigned int _length;
|
||||||
|
|
||||||
unsigned int find_sorted_id(Track *);
|
unsigned int find_sorted_id(Track *);
|
||||||
|
unsigned int _add_at(Track *, unsigned int);
|
||||||
void _add_sort(sort_t, bool);
|
void _add_sort(sort_t, bool);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -48,8 +49,7 @@ public:
|
||||||
|
|
||||||
std::string get_length_str();
|
std::string get_length_str();
|
||||||
|
|
||||||
unsigned int add(Track *);
|
virtual unsigned int add(Track *);
|
||||||
unsigned int add_front(unsigned int);
|
|
||||||
void del(unsigned int);
|
void del(unsigned int);
|
||||||
void del_track(unsigned int);
|
void del_track(unsigned int);
|
||||||
void track_updated(unsigned int);
|
void track_updated(unsigned int);
|
||||||
|
|
|
@ -19,9 +19,20 @@ static bool o_pause_enabled = false;
|
||||||
static unsigned int o_pause_count = 0;
|
static unsigned int o_pause_count = 0;
|
||||||
static bool o_should_pause = false;
|
static bool o_should_pause = false;
|
||||||
|
|
||||||
static Queue o_recently_played(Q_ENABLED | Q_REPEAT | Q_NO_SORT | Q_DISABLE_CHANGED_SIZE);
|
|
||||||
static File f_cur_track("cur_track");
|
static File f_cur_track("cur_track");
|
||||||
|
|
||||||
|
|
||||||
|
class RecentQueue : public Queue
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RecentQueue()
|
||||||
|
: Queue(Q_ENABLED | Q_REPEAT | Q_NO_SORT | Q_DISABLE_CHANGED_SIZE) {}
|
||||||
|
unsigned int add(Track *track) { return _add_at(track, 0); }
|
||||||
|
};
|
||||||
|
|
||||||
|
static RecentQueue o_recently_played;
|
||||||
|
|
||||||
|
|
||||||
static void parse_error(GstMessage *error)
|
static void parse_error(GstMessage *error)
|
||||||
{
|
{
|
||||||
GError *err;
|
GError *err;
|
||||||
|
@ -197,7 +208,7 @@ void audio :: next()
|
||||||
cur_trackid = track->id;
|
cur_trackid = track->id;
|
||||||
save_state();
|
save_state();
|
||||||
o_recently_played.del_track(track->id);
|
o_recently_played.del_track(track->id);
|
||||||
o_recently_played.add_front(track->id);
|
o_recently_played.add(track);
|
||||||
o_recently_played.set_cur(0);
|
o_recently_played.set_cur(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +242,7 @@ void audio :: load_trackid(unsigned int track_id)
|
||||||
cur_trackid = track_id;
|
cur_trackid = track_id;
|
||||||
save_state();
|
save_state();
|
||||||
o_recently_played.del_track(track_id);
|
o_recently_played.del_track(track_id);
|
||||||
o_recently_played.add_front(track_id);
|
o_recently_played.add(track);
|
||||||
o_recently_played.set_cur(0);
|
o_recently_played.set_cur(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,31 +149,22 @@ unsigned int Queue :: find_sorted_id(Track *rhs)
|
||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Queue :: _add_at(Track *track, unsigned int pos)
|
||||||
|
{
|
||||||
|
_tracks.insert(_tracks.begin() + pos, track);
|
||||||
|
_length += track->length;
|
||||||
|
get_callbacks()->on_queue_track_add(this, pos);
|
||||||
|
if (!(_flags & Q_DISABLE_CHANGED_SIZE))
|
||||||
|
get_callbacks()->on_queue_changed();
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int Queue :: add(Track *track)
|
unsigned int Queue :: add(Track *track)
|
||||||
{
|
{
|
||||||
unsigned int id = _tracks.size();
|
unsigned int id = _tracks.size();
|
||||||
|
|
||||||
if (_sort_order.size() > 0)
|
if (_sort_order.size() > 0)
|
||||||
id = find_sorted_id(track);
|
id = find_sorted_id(track);
|
||||||
|
return _add_at(track, id);
|
||||||
_tracks.insert(_tracks.begin() + id, track);
|
|
||||||
_length += track->length;
|
|
||||||
get_callbacks()->on_queue_track_add(this, id);
|
|
||||||
if (!(_flags & Q_DISABLE_CHANGED_SIZE))
|
|
||||||
get_callbacks()->on_queue_changed();
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Queue :: add_front(unsigned int track_id)
|
|
||||||
{
|
|
||||||
Track *track = tagdb :: lookup(track_id);
|
|
||||||
_tracks.insert(_tracks.begin(), track);
|
|
||||||
|
|
||||||
_length += track->length;
|
|
||||||
get_callbacks()->on_queue_track_add(this, 0);
|
|
||||||
if (!(_flags & Q_DISABLE_CHANGED_SIZE))
|
|
||||||
get_callbacks()->on_queue_changed();
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Queue :: del(unsigned int plist_id)
|
void Queue :: del(unsigned int plist_id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user