bcf9aea3e44b52c1c06c4d6bd88a63a8da9feee5
[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 QAbstractTableModel
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     //this Enum MUST BE sequantial
27     //And when changed must update the length
28 #define PLAYLISTENUMS 8
29     enum coulmnStruct
30     {
31         sName,
32         sID,
33         sKey,
34         sURL,
35         sBuff,
36         sDownloaded,
37         sPlayed,
38         sReady,
39     };
40
41     struct songElement
42     {
43         QString *name;
44         QString *songId;
45         QString *streamkey;
46         QUrl *server;
47         QBuffer *buffer;
48         QIODevice *data;
49         elementType type;
50         bool downloaded;
51         bool played;
52         bool bufferready;
53     };
54     QList<songElement *>* getList();
55     explicit playlist(QObject *parent = 0);
56     int addSong(QStandardItem *item,QString name);
57     void removeSong(int position);
58     void getSong(int position);
59     QIODevice * getBuffer(int position);
60     bool isStream(int position);
61     void markPlayed(int position);
62     void deleteSong(int position);
63     void setGscom(gscom *comm);
64     void freeMemory(int position);
65     int currentplaying();
66     void setCurrentPlaying(int position);
67     bool bReady(int b);
68     int findFirstNotPlayed();
69     void beginDownload(int position);
70     bool existAt(int position);
71
72     //Implemented virtual classes for Model View
73     QVariant data(const QModelIndex &index, int role) const;
74     int columnCount(const QModelIndex &parent) const;
75     int rowCount(const QModelIndex &parent) const;
76
77 signals:
78     void downloadProgress(int position, qint64 d, qint64 t);
79     void bufferReady(int position);
80     void sFailure(int position,failType);
81     void downloadComplete(int position);
82     void freeze(bool);
83     //void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
84     void rowsInserted ( const QModelIndex & parent, int start, int end );
85
86 public slots:
87 private slots:
88     void downloadSlot(qint64 d, qint64 t);
89     void networkReplyFinish();
90     void downloadDone(int position);
91     void skeyFound();
92     void setBufferRdy(int b);
93     void getNError(QNetworkReply::NetworkError);
94 private:
95
96
97
98
99
100     int currentplayingitem;
101     int currentSkeyItem;
102     QList<songElement *> *pList;
103     QSignalMapper *mapper;
104     QNetworkReply *reply;
105     QNetworkAccessManager *manager;
106     int currentdownloaditem;
107     gscom *gs;
108     QTime startStreamT;
109 };
110
111 #endif // PLAYLIST_H