5 #include <QNetworkReply>
9 enum DownloadItemStatus {
17 class DownloadItem : public QObject {
23 void bufferProgress(int percent);
24 void progress(int percent);
29 DownloadItem(Video *video, QUrl url, QString filename, QObject *parent = 0);
31 qint64 bytesTotal() const;
32 qint64 bytesReceived() const;
33 double remainingTime() const;
34 double totalTime() { return m_totalTime; }
35 double currentSpeed() const;
36 int currentPercent() const { return percent; }
37 Video* getVideo() const { return video; }
38 QString currentFilename() const { return m_file.fileName(); }
39 DownloadItemStatus status() const { return m_status; }
40 static QString formattedFilesize(qint64 size);
41 static QString formattedSpeed(double speed);
42 static QString formattedTime(double time, bool remaining = true);
43 QString errorMessage() const;
53 void downloadReadyRead();
54 void error(QNetworkReply::NetworkError code);
55 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
56 void metaDataChanged();
57 void requestFinished();
58 void gotStreamUrl(QUrl streamUrl);
63 int initialBufferSize();
65 qint64 m_bytesReceived;
68 bool m_finishedDownloading;
69 QTime m_lastProgressTime;
76 QNetworkReply *m_reply;
79 DownloadItemStatus m_status;
80 QString m_errorMessage;
82 QTimer *speedCheckTimer;
86 // This is required in order to use QPointer<DownloadItem> as a QVariant
87 // as used by the Model/View playlist
88 typedef QPointer<DownloadItem> DownloadItemPointer;
89 Q_DECLARE_METATYPE(DownloadItemPointer)
91 #endif // DOWNLOADITEM_H