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);
29 qint64 bytesTotal() const;
30 qint64 bytesReceived() const;
31 double remainingTime() const;
32 double currentSpeed() const;
33 int currentPercent() const { return percent; }
34 Video* getVideo() const { return video; }
35 QString currentFilename() const { return m_file.fileName(); }
36 DownloadItemStatus status() const { return m_status; }
37 static QString formattedFilesize(qint64 size);
38 static QString formattedSpeed(double speed);
39 static QString formattedTime(double time);
40 QString errorMessage() const;
50 void downloadReadyRead();
51 void error(QNetworkReply::NetworkError code);
52 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
53 void metaDataChanged();
54 void requestFinished();
59 qint64 m_bytesReceived;
62 bool m_finishedDownloading;
63 QTime m_lastProgressTime;
69 QNetworkReply *m_reply;
72 DownloadItemStatus m_status;
73 QString m_errorMessage;
77 // This is required in order to use QPointer<DownloadItem> as a QVariant
78 // as used by the Model/View playlist
79 typedef QPointer<DownloadItem> DownloadItemPointer;
80 Q_DECLARE_METATYPE(DownloadItemPointer)
82 #endif // DOWNLOADITEM_H