7d3c215d5ab95b055477d3b34d3cc139715ee929
[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 elementType
16     {
17         EStream = 1,
18         EFile = 2,
19     };
20     enum failType
21     {
22         none = 0,
23         Aborted = 1,
24         Other =2
25     };
26     struct songElement
27     {
28         QString *songId;
29         QString *streamkey;
30         QUrl *server;
31         QBuffer *buffer;
32         QIODevice *data;
33         elementType type;
34         bool downloaded;
35         bool played;
36         bool bufferready;
37     };
38     QList<songElement *>* getList();
39     explicit playlist(QObject *parent = 0);
40     int addSong(QStandardItem *item);
41     QList<QStandardItem *> getPlaylist();
42     void removeSong(int position);
43     void getSong(int position);
44     QIODevice * getBuffer(int position);
45     bool isStream(int position);
46     void markPlayed(int position);
47     void deleteSong(int position);
48     void setGscom(gscom *comm);
49     void freeMemory(int position);
50     int currentplaying();
51     void setCurrentPlaying(int position);
52     bool bReady(int b);
53     int findFirstNotPlayed();
54     void beginDownload(int position);
55     bool existAt(int position);
56
57 signals:
58     void downloadProgress(int position, qint64 d, qint64 t);
59     void bufferReady(int position);
60     void sFailure(int position,failType);
61     void downloadComplete(int position);
62     void freeze(bool);
63
64 public slots:
65 private slots:
66     void downloadSlot(qint64 d, qint64 t);
67     void networkReplyFinish();
68     void downloadDone(int position);
69     void skeyFound();
70     void setBufferRdy(int b);
71     void getNError(QNetworkReply::NetworkError);
72 private:
73
74
75
76
77
78     int currentplayingitem;
79     int currentSkeyItem;
80     QList<songElement *> *pList;
81     QSignalMapper *mapper;
82     QNetworkReply *reply;
83     QNetworkAccessManager *manager;
84     int currentdownloaditem;
85     gscom *gs;
86     QTime startStreamT;
87 };
88
89 #endif // PLAYLIST_H