5 #include <QNetworkReply>
9 enum DownloadItemStatus {
17 class DownloadItem : public QObject {
23 void progress(int percent);
27 DownloadItem(Video *video, QUrl url, QString filename, QObject *parent = 0);
28 qint64 bytesTotal() const;
29 qint64 bytesReceived() const;
30 double remainingTime() const;
31 double currentSpeed() const;
32 int currentPercent() const { return percent; }
33 Video* getVideo() const { return video; }
34 DownloadItemStatus status() const { return m_status; }
35 static QString formattedFilesize(qint64 size);
36 static QString formattedSpeed(double speed);
37 static QString formattedTime(double time);
38 QString errorMessage() const;
48 void downloadReadyRead();
49 void error(QNetworkReply::NetworkError code);
50 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
51 void metaDataChanged();
52 void requestFinished();
57 qint64 m_bytesReceived;
60 bool m_finishedDownloading;
61 QTime m_lastProgressTime;
67 QNetworkReply *m_reply;
70 DownloadItemStatus m_status;
71 QString m_errorMessage;
75 // This is required in order to use QPointer<DownloadItem> as a QVariant
76 // as used by the Model/View playlist
77 typedef QPointer<DownloadItem> DownloadItemPointer;
78 Q_DECLARE_METATYPE(DownloadItemPointer)
80 #endif // DOWNLOADITEM_H