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 currentSpeed() const;
35 int currentPercent() const { return percent; }
36 Video* getVideo() const { return video; }
37 QString currentFilename() const { return m_file.fileName(); }
38 DownloadItemStatus status() const { return m_status; }
39 static QString formattedFilesize(qint64 size);
40 static QString formattedSpeed(double speed);
41 static QString formattedTime(double time);
42 QString errorMessage() const;
52 void downloadReadyRead();
53 void error(QNetworkReply::NetworkError code);
54 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
55 void metaDataChanged();
56 void requestFinished();
57 void gotStreamUrl(QUrl streamUrl);
62 int initialBufferSize();
64 qint64 m_bytesReceived;
67 bool m_finishedDownloading;
68 QTime m_lastProgressTime;
74 QNetworkReply *m_reply;
77 DownloadItemStatus m_status;
78 QString m_errorMessage;
80 QTimer *speedCheckTimer;
84 // This is required in order to use QPointer<DownloadItem> as a QVariant
85 // as used by the Model/View playlist
86 typedef QPointer<DownloadItem> DownloadItemPointer;
87 Q_DECLARE_METATYPE(DownloadItemPointer)
89 #endif // DOWNLOADITEM_H