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