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