// Following line is crucial becouse sourceforge wont redirect correctly
// if no user-agent is supplied
request.setRawHeader("User-Agent", "Wget/1.12 (linux-gnu)");
- manager->get(request);
+ currentReply = manager->get(request);
+ connect(currentReply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SIGNAL(progress(qint64,qint64)));
}
void HttpDownloader::downloadFinished(QNetworkReply *reply) {
+ disconnect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SIGNAL(progress(qint64,qint64)));
if(reply->error() != QNetworkReply::NoError) {
Q_EMIT error(reply->errorString());
return;
QNetworkRequest req;
req.setRawHeader("User-Agent", "Wget/1.12 (linux-gnu)");
req.setUrl(r);
- manager->get(req);
+ currentReply = manager->get(req);
+ connect(currentReply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SIGNAL(progress(qint64,qint64)));
}
else {
QFile resultFile(destFile);
Q_SIGNALS:
void finished();
void error(QString);
+ void progress(qint64,qint64);
private:
QHttp *http;
QNetworkAccessManager *manager;
QString destFile;
+ QNetworkReply* currentReply;
};
}
void XdxfDialog::downloadFile() {
- qDebug()<<"a";
XdxfPlugin::dictDownloader.download(this);
}
#endif
}
+void XdxfDictDownloadProgressDialog::show() {
+ downloadProgressBar->setMaximum(0);
+ QDialog::show();
+}
void XdxfDictDownloadProgressDialog::setText(QString text) {
setWindowTitle(text);
#endif
}
+void XdxfDictDownloadProgressDialog::updateProgress(float progress) {
+ if(downloadProgressBar->maximum() == 0) {
+ downloadProgressBar->setMaximum(100);
+ }
+ downloadProgressBar->setValue(progress*100);
+}
+
void XdxfDictDownloadProgressDialog::reject() {
#ifndef Q_WS_MAEMO_5
Q_EMIT cancelDownloading();
//! Set text which will be displayed to user as info about current download
void setText(QString);
+ void updateProgress(float progress);
+
+ void show();
+
Q_SIGNALS:
//! signal emitted when user cancels downloading of a dictionary
void cancelDownloading();
+
private:
QLabel* downloadLabel;
QProgressBar* downloadProgressBar;
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) {
connect(progressDialog, SIGNAL(cancelDownloading()),
this, SLOT(breakDownloading()));
+ connect(this, SIGNAL(downloadProgress(float)),
+ progressDialog, SLOT(updateProgress(float)));
+
progressDialog->setText(tr("Downloading dictionaries list"));
progressDialog->show();
}
return _downloadedFile;
}
+void XdxfDictDownloader::updateDownloadProgress(qint64 downloaded,
+ qint64 total) {
+ Q_EMIT downloadProgress(float(downloaded) / float(total));
+}
void XdxfDictDownloader::downloadingError(QString error) {
breakDownloading();
//! emitted to inform user about errors and warnings
void notify(Notify::NotifyType, QString);
+ void downloadProgress(float);
+
private Q_SLOTS:
//! obtained list of dictionaries from website
void dictListReceived(QNetworkReply*);
void downloadingError(QString);
+ void updateDownloadProgress(qint64, qint64);
+
private:
//! dict is downloaded and unpacked
void downloadComplete();