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 QString currentFilename() const { return m_file.fileName(); }
35 DownloadItemStatus status() const { return m_status; }
36 static QString formattedFilesize(qint64 size);
37 static QString formattedSpeed(double speed);
38 static QString formattedTime(double time);
39 QString errorMessage() const;
49 void downloadReadyRead();
50 void error(QNetworkReply::NetworkError code);
51 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
52 void metaDataChanged();
53 void requestFinished();
58 qint64 m_bytesReceived;
61 bool m_finishedDownloading;
62 QTime m_lastProgressTime;
68 QNetworkReply *m_reply;
71 DownloadItemStatus m_status;
72 QString m_errorMessage;
76 // This is required in order to use QPointer<DownloadItem> as a QVariant
77 // as used by the Model/View playlist
78 typedef QPointer<DownloadItem> DownloadItemPointer;
79 Q_DECLARE_METATYPE(DownloadItemPointer)
81 #endif // DOWNLOADITEM_H