X-Git-Url: https://git.sur5r.net/?p=minitube;a=blobdiff_plain;f=src%2Fdownloaditem.cpp;h=c919e2aaa74a041ad6aa09eb4680c5b945282a5a;hp=36652f6c338a31278c932636953013e27cb4c815;hb=57c25e20a8f10a98a18dbc2b64ce55cf87d4fd7c;hpb=63b7586c1282acfb82a9b1971320052d6ee0a707 diff --git a/src/downloaditem.cpp b/src/downloaditem.cpp index 36652f6..c919e2a 100644 --- a/src/downloaditem.cpp +++ b/src/downloaditem.cpp @@ -3,6 +3,7 @@ #include "video.h" #include +#include namespace The { NetworkAccess* http(); @@ -131,12 +132,8 @@ void DownloadItem::downloadReadyRead() { void DownloadItem::error(QNetworkReply::NetworkError) { -#ifdef DOWNLOADMANAGER_DEBUG - qDebug() << "DownloadItem::" << __FUNCTION__ << m_reply->errorString() << m_url; -#endif - if (m_reply) { - qDebug() << m_reply->errorString(); + qWarning() << m_reply->errorString() << m_reply->url().toEncoded(); m_errorMessage = m_reply->errorString(); } @@ -181,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(); @@ -193,7 +192,7 @@ void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { int bufferSize = initialBufferSize(); if (bytesReceived > bufferSize && bytesReceived > neededBytes - && m_downloadTime.elapsed() > 1000 ) { + && (m_downloadTime.elapsed() > 1000)) { emit bufferProgress(100); m_status = Downloading; emit statusChanged(); @@ -279,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();