diff options
| author | Jonathan Bauer | 2011-03-15 23:37:21 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-15 23:37:21 +0100 |
| commit | f895dda6697c9c5edab87e7263d9c38a17ccb811 (patch) | |
| tree | 3186bd8b6bf1a94079068546182f457e19898df2 /src/downloadManager.cpp | |
| parent | fbgui.conf default paths checks, update interval modifiable (only in .conf), ... (diff) | |
| download | fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.tar.gz fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.tar.xz fbgui-f895dda6697c9c5edab87e7263d9c38a17ccb811.zip | |
fixes
Diffstat (limited to 'src/downloadManager.cpp')
| -rw-r--r-- | src/downloadManager.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp index dca99d3..f7a6372 100644 --- a/src/downloadManager.cpp +++ b/src/downloadManager.cpp @@ -19,7 +19,8 @@ downloadManager::downloadManager() else if (debug) qDebug() << "Download directory: " << downloadDir.path() << "exists."; } // ---------------------------------------------------------------------------------------- -void downloadManager::downloadFile(QString& filename){ +void downloadManager::downloadFile(QString& filename) +{ if (debug) qDebug() << "Received downloadFile signal for:" << filename; QUrl fileUrl; fileUrl = baseURL.resolved(QUrl(filename)); @@ -27,7 +28,8 @@ void downloadManager::downloadFile(QString& filename){ this->processDownloadRequest(fileUrl); } // ---------------------------------------------------------------------------------------- -void downloadManager::downloadFile(QUrl& fileUrl){ +void downloadManager::downloadFile(QUrl& fileUrl) +{ if (debug) qDebug() << "Received downloadFile signal for:" << fileUrl; this->processDownloadRequest(fileUrl); } @@ -88,6 +90,7 @@ void downloadManager::startNextDownload() } lastProgress = 0; + currentProgress = 0; dip = true; QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT(downloadReady())); QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)), @@ -105,9 +108,14 @@ void downloadManager::downloadReady() // ---------------------------------------------------------------------------------------- void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { + if (bytesIn > bytesTotal) + return; + /* Update progress only if difference higher than the updateInterval setting */ - int currentProgress = ((bytesIn * 100) / bytesTotal); - if (currentProgress - lastProgress > updateInterval){ + int tmp = ((bytesIn * 100) / bytesTotal); + if (tmp > 0) + currentProgress = tmp; + if (currentProgress - lastProgress >= updateInterval){ lastProgress = currentProgress; emit updateProgress(currentDownload->url().toString(), currentProgress); if (debug) qDebug() << "Download progress of " << currentDownload->url().toString() @@ -118,7 +126,7 @@ void downloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) // ---------------------------------------------------------------------------------------- void downloadManager::downloadFinished() { - /* Header filename fetching & renaming, old-ish + /* Header filename fetching & renaming const QByteArray cd = "Content-Disposition"; QByteArray cdc = currentDownload->rawHeader(cd); int x = cdc.indexOf("filename=\"") + 10; @@ -154,4 +162,5 @@ void downloadManager::downloadFinished() } startNextDownload(); } +// ---------------------------------------------------------------------------------------- |
