X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdownloaditem.cpp;h=c919e2aaa74a041ad6aa09eb4680c5b945282a5a;hb=df8b2c951e66b538dd4d191220e883d86b700864;hp=f70624be170554c1275c5436aa5216150d42f819;hpb=c449f3a0f783b74807783ab9618d4b8232e4fae3;p=minitube diff --git a/src/downloaditem.cpp b/src/downloaditem.cpp index f70624b..c919e2a 100644 --- a/src/downloaditem.cpp +++ b/src/downloaditem.cpp @@ -3,6 +3,7 @@ #include "video.h" #include +#include namespace The { NetworkAccess* http(); @@ -131,13 +132,11 @@ void DownloadItem::downloadReadyRead() { void DownloadItem::error(QNetworkReply::NetworkError) { -#ifdef DOWNLOADMANAGER_DEBUG - qDebug() << "DownloadItem::" << __FUNCTION__ << m_reply->errorString() << m_url; -#endif - - qDebug() << m_reply->errorString(); + if (m_reply) { + qWarning() << m_reply->errorString() << m_reply->url().toEncoded(); + m_errorMessage = m_reply->errorString(); + } - m_errorMessage = m_reply->errorString(); m_reply = 0; m_status = Failed; @@ -179,6 +178,8 @@ int DownloadItem::initialBufferSize() { void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { + // qDebug() << bytesReceived << bytesTotal << m_downloadTime.elapsed(); + if (m_lastProgressTime.elapsed() < 150) return; m_lastProgressTime.start(); @@ -186,12 +187,12 @@ void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if (m_status != Downloading) { - int neededBytes = (int) (bytesTotal * .01); + int neededBytes = (int) (bytesTotal * .001); // qDebug() << bytesReceived << bytesTotal << neededBytes << m_downloadTime.elapsed(); int bufferSize = initialBufferSize(); if (bytesReceived > bufferSize && bytesReceived > neededBytes - && m_downloadTime.elapsed() > 1000 ) { + && (m_downloadTime.elapsed() > 1000)) { emit bufferProgress(100); m_status = Downloading; emit statusChanged(); @@ -277,6 +278,10 @@ void DownloadItem::requestFinished() { qDebug() << "Request finished but never started saving"; return; } + if (m_status == Starting) { + m_status = Downloading; + emit statusChanged(); + } m_file.close(); m_status = Finished; emit statusChanged();