]> git.sur5r.net Git - minitube/blobdiff - src/downloaditem.h
Switch watchfile to Github API
[minitube] / src / downloaditem.h
index 58bb49353e87d5dbbb5c567df9c461d2820d079d..2c074f0c1d7a4076dd26df647ee40e6e114f2b65 100644 (file)
@@ -1,3 +1,23 @@
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
 #ifndef DOWNLOADITEM_H
 #define DOWNLOADITEM_H
 
@@ -31,6 +51,7 @@ public:
     qint64 bytesTotal() const;
     qint64 bytesReceived() const;
     double remainingTime() const;
+    double totalTime() { return m_totalTime; }
     double currentSpeed() const;
     int currentPercent() const { return percent; }
     Video* getVideo() const { return video; }
@@ -38,8 +59,13 @@ public:
     DownloadItemStatus status() const { return m_status; }
     static QString formattedFilesize(qint64 size);
     static QString formattedSpeed(double speed);
-    static QString formattedTime(double time);
+    static QString formattedTime(double time, bool remaining = true);
     QString errorMessage() const;
+    qint64 offset() const { return m_offset; }
+    bool needsDownload(qint64 offset);
+    bool isBuffered(qint64 offset);
+    qint64 blankAtOffset(qint64 offset);
+    void seekTo(qint64 offset, bool sendStatusChanges = true);
 
 public slots:
     void start();
@@ -67,9 +93,13 @@ private:
     bool m_finishedDownloading;
     QTime m_lastProgressTime;
     int percent;
+    double m_totalTime;
 
     QUrl m_url;
 
+    qint64 m_offset;
+    bool sendStatusChanges;
+
     QFile m_file;
     QNetworkReply *m_reply;
     Video *video;
@@ -79,6 +109,7 @@ private:
 
     QTimer *speedCheckTimer;
 
+    QMap<qint64, qint64> buffers;
 };
 
 // This is required in order to use QPointer<DownloadItem> as a QVariant