Add an icon (inkscape SVG)
[groove] / playlist.h
1 #ifndef PLAYLIST_H
2 #define PLAYLIST_H
3
4 #include <QObject>
5 #include <QStandardItem>
6 #include <QBuffer>
7 #include <QNetworkReply>
8 #include <QList>
9 #include <QSignalMapper>
10 #include <gscom.h>
11 class playlist : public QObject
12 {
13     Q_OBJECT
14 public:
15     enum failType
16     {
17         none = 0,
18         Aborted = 1,
19         Other =2
20     };
21     explicit playlist(QObject *parent = 0);
22     void addSong(QStandardItem item);
23     void addSong(QString songid);
24     void addsong(QString streamkey, QUrl server);
25     QList<QStandardItem *> getPlaylist();
26     void removeSong(int position);
27     void getSong(int position);
28     QIODevice * getBuffer(int position);
29     bool isStream(int position);
30     void markComplete(int position);
31     void deleteSong(int position);
32     void setGscom(gscom *comm);
33
34 signals:
35     void downloadProgress(int position, qint64 d, qint64 t);
36     void bufferReady(int position);
37     void sFailure(int position,failType);
38     void downloadComplete(int position);
39     void freeze();
40     void unfreeze();
41
42 public slots:
43 private slots:
44     void downloadSlot(qint64 d, qint64 t);
45     void downloadDone(int position);
46     void skeyFound();
47 private:
48     void beginDownload(int position);
49     enum elementType
50     {
51         EStream = 1,
52         EFile = 2,
53     };
54
55     struct songElement
56     {
57         QString *songId;
58         QString *streamkey;
59         QUrl *server;
60         QBuffer *buffer;
61         QIODevice *data;
62         elementType type;
63         bool downloaded;
64         bool played;
65         bool bufferready;
66     };
67     int currentSkeyItem;
68     QList<songElement *> *pList;
69     QSignalMapper *mapper;
70     QNetworkReply *reply;
71     QNetworkAccessManager *manager;
72     int currentdownloaditem;
73     gscom *gs;
74     QTime startStreamT;
75 };
76
77 #endif // PLAYLIST_H