diff options
| author | Jonathan Bauer | 2011-03-09 21:04:51 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-09 21:04:51 +0100 |
| commit | 3e018bf61b264d7f02df0d436b2a6aa163a926d7 (patch) | |
| tree | 6981b296e58c89548408177727a69080fc6af515 /src/DownloadManager.cpp | |
| parent | DM also provides current file on update (diff) | |
| download | fbgui-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.cpp | 14 |
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 |
