Added download progress notification
[mdictionary] / src / plugins / xdxf / XdxfDictDownloader.cpp
index 38066f4..908f1ef 100644 (file)
@@ -50,6 +50,9 @@ XdxfDictDownloader::XdxfDictDownloader(QObject *parent) :
     connect(&http, SIGNAL(finished()), this, SLOT(processFinished()));
     connect(&http, SIGNAL(error(QString)),
             this, SLOT(downloadingError(QString)));
+    connect(&http, SIGNAL(progress(qint64,qint64)),
+            this, SLOT(updateDownloadProgress(qint64,qint64)));
+
 }
 
 void XdxfDictDownloader::download(QWidget *parent) {
@@ -62,6 +65,9 @@ void XdxfDictDownloader::download(QWidget *parent) {
 
     connect(progressDialog, SIGNAL(cancelDownloading()),
             this, SLOT(breakDownloading()));
+    connect(this, SIGNAL(downloadProgress(float)),
+            progressDialog, SLOT(updateProgress(float)));
+
     progressDialog->setText(tr("Downloading dictionaries list"));
     progressDialog->show();
 }
@@ -70,6 +76,10 @@ QString XdxfDictDownloader::downloadedFile() {
     return _downloadedFile;
 }
 
+void XdxfDictDownloader::updateDownloadProgress(qint64 downloaded,
+                                                qint64 total)   {
+    Q_EMIT downloadProgress(float(downloaded) / float(total));
+}
 
 void XdxfDictDownloader::downloadingError(QString error) {
     breakDownloading();