diff --git a/filedownloader.cpp b/filedownloader.cpp index 63ceebb..127e45b 100644 --- a/filedownloader.cpp +++ b/filedownloader.cpp @@ -51,6 +51,7 @@ int FileDownloader::startNextDownload(QString fileName, QString courseName, QStr ui->dateinameLabel->setText(fileName); ui->progressBar->setFormat(QString("%v ") % correctUnit(itemSize) % " / %m " % correctUnit(itemSize)); ui->progressBar->setMaximum(correctSize(itemSize)); + ui->downloadSpeedLabel->setText(""); times.actime = 0; times.modtime = time; @@ -65,6 +66,8 @@ int FileDownloader::startNextDownload(QString fileName, QString courseName, QStr return 0; } + downloadTime.start(); + // Start des Requests reply = manager->get(QNetworkRequest(fileUrl)); QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgressSlot(qint64,qint64))); @@ -83,6 +86,10 @@ void FileDownloader::downloadProgressSlot(qint64 bytesReceived, qint64 bytesTota // Aktualisieren der Progressbar anhand der Größe der empfangenen Bytes ui->progressBar->setValue(correctSize(bytesReceived)); ui->progressBar->update(); + + // Downloadgeschwindigkeit in kB/s + int downloadSpeed = bytesReceived * 1000 / downloadTime.elapsed() / 1024; + ui->downloadSpeedLabel->setText(QString::number(downloadSpeed) % " kB/s"); } /// Abspeichern von empfangenen Dateiteilen diff --git a/filedownloader.h b/filedownloader.h index f03b571..2042a3b 100644 --- a/filedownloader.h +++ b/filedownloader.h @@ -66,6 +66,8 @@ class FileDownloader : public QDialog QString correctUnit(qint64 bytes); qint64 correctSize(qint64 bytes); + QTime downloadTime; + private slots: void downloadProgressSlot(qint64,qint64); void readyReadSlot();