blob: dd4022ba05671f83406cf9616a26db7407de6b7a (
plain) (
tree)
|
|
/*
* FileDownloader.cpp
*
* Created on: Mar 7, 2014
* Author: nils
*/
#include <QFileInfo>
#include "FileDownloader.h"
FileDownloader::FileDownloader(QObject *parent) :
QObject(parent) {
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
SLOT(fileDownloaded(QNetworkReply*)));
}
FileDownloader::~FileDownloader() {
}
void FileDownloader::connectSlot(QObject* obj, const char* slot) {
QObject::connect(this, SIGNAL(downloaded(QString&, QByteArray)),
obj, slot);
}
void FileDownloader::fileDownloaded(QNetworkReply* pReply) {
QByteArray downloadedData = pReply->readAll();
//emit a signal
pReply->deleteLater();
emit downloaded(this->fileName, downloadedData);
this->deleteLater();
}
void FileDownloader::downloadFile(const QUrl& fileUrl) {
this->fileName = fileUrl.toString();
m_WebCtrl.get(QNetworkRequest(fileUrl));
}
|