#include "DownloadManager.h" void DownloadManager::downloadFile(QString& filename) { QUrl u = this->baseUrl.resolved(filename); this->request.setUrl(u); this->filename = filename; this->reply = this->qnam->get(this->request); this->qiod = reply; QObject::connect(this->reply, SIGNAL(finished()), this, SLOT(saveData())); } void DownloadManager::saveData() { QFile outfile(this->filename); if (!outfile.open(QIODevice::WriteOnly)) { qDebug() << "Couldnt open file! exiting..."; exit(1); } outfile.write(this->qiod->readAll()); outfile.close(); } void DownloadManager::setUrl(QUrl& qurl) { this->baseUrl = qurl; } void DownloadManager::print() { qDebug() << "The download manager is still working"; } DownloadManager::DownloadManager() { this->qnam = new QNetworkAccessManager(); } DownloadManager::~DownloadManager() { }