ocarina/include/playlist.h
Bryan Schumaker e116025754 libsaria: Fix playlist bulk insert
My "insert while sorted" code was getting complicated, and didn't send
all the notifications to the UI (only the first ~1200 songs were
displayed).  This patch both simplifies the code and produces the right
answer without a noticable performance penalty.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
2012-11-03 21:43:52 -04:00

97 lines
1.9 KiB
C++

// Copyright (c) 2012 Bryan Schumaker.
#ifndef LIBSARIA_PLAYLIST_H
#define LIBSARIA_PLAYLIST_H
#include <notify.h>
#include <index.h>
#include <fs.h>
#include <list>
#include <string>
#include <vector>
using namespace std;
enum PlaylistFlags {
PL_NONE = (0),
PL_NO_DRAIN = (1 << 0),
PL_STATIC = (1 << 1),
PL_DISABLED = (1 << 2),
PL_RANDOM = (1 << 3),
PL_SORTED = (1 << 4),
};
namespace libsaria
{
/* Forward declaration of Track class */
class Track;
class Playlist {
private:
int number;
unsigned int flags;
DataState data_state;
unsigned int cur;
Index index;
void set_flag(bool, PlaylistFlags);
void schedule_save();
void rm_file();
void notify_ui(notify_t, Track *, unsigned int);
void notify_update_all();
unsigned int find_index(Track *);
void add_track(Track *, unsigned int);
void insert_sorted(Track *);
void do_remove_tracks(list<Track *> &);
void remove_index(unsigned int);
void do_sort();
protected:
vector<Track *> plist;
public:
Playlist(unsigned int);
virtual ~Playlist();
void push_front(Track *);
void push_back(Track *);
void push_back(list<Track *> &);
Track *next();
void set_random(bool);
bool get_random();
void set_sorted(bool);
bool get_sorted();
void save(ofstream &);
bool is_static();
bool is_disabled();
void prepare_for_removal();
void reset_iterator();
void set_filter_text(string &);
bool is_visible(libsaria::Track *);
void set_disabled(bool);
void renumber(int);
unsigned int get_number();
unsigned int get_size();
unsigned int get_length();
void remove_indices(list<unsigned int> &);
void remove_track(Track *);
void track_updated(Track *);
};
struct PlaylistNotification {
Playlist *plist;
Track *track;
unsigned int index;
};
}; /* Namespace: libsaria */
#endif /* LIBSARIA_PLAYLIST_H */