summaryrefslogtreecommitdiffstats
path: root/src/DownloadManager.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-09 21:04:51 +0100
committerJonathan Bauer2011-03-09 21:04:51 +0100
commit3e018bf61b264d7f02df0d436b2a6aa163a926d7 (patch)
tree6981b296e58c89548408177727a69080fc6af515 /src/DownloadManager.cpp
parentDM also provides current file on update (diff)
downloadfbgui-3e018bf61b264d7f02df0d436b2a6aa163a926d7.tar.gz
fbgui-3e018bf61b264d7f02df0d436b2a6aa163a926d7.tar.xz
fbgui-3e018bf61b264d7f02df0d436b2a6aa163a926d7.zip
DM: update sends only signals if the progress difference is >1%
Diffstat (limited to 'src/DownloadManager.cpp')
-rw-r--r--src/DownloadManager.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp
index 9f59010..ec723a9 100644
--- a/src/DownloadManager.cpp
+++ b/src/DownloadManager.cpp
@@ -96,6 +96,7 @@ void DownloadManager::startNextDownload()
return;
}
dip = true;
+ currentProgress = 0;
QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT(downloadReady()));
QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)),
this, SLOT(downloadProgress(qint64, qint64)));
@@ -111,15 +112,20 @@ void DownloadManager::downloadReady()
outfile.write(currentDownload->readAll());
}
// ----------------------------------------------------------------------------------------
-// This slot listens to the downloadProgress(..)
-// which provides information on the download progress of the file.
+// This triggers sends the update progress back to the site.
void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal)
{
if (debug) qDebug() << "Download progress of " << currentDownload->url().toString()
<< ": " << bytesIn << "/" << bytesTotal;
- qint64 tmp = ((bytesIn * 100) / bytesTotal);
- emit updateProgress(currentDownload->url().toString(), (int)tmp);
+
+ int tmp = ((bytesIn * 100) / bytesTotal);
+ if (tmp > currentProgress){
+ currentProgress = tmp;
+ emit updateProgress(currentDownload->url().toString(), tmp);
+ }
+ // Progress difference < 1%
+ return;
}
// ----------------------------------------------------------------------------------------
// This slot listens to the finished() which is emmited