#include "DownloadManager.h" void DownloadManager::downloadFile(QString& filename) { QUrl u = this->baseUrl.resolved(filename); this->request.setUrl(u); this->filename = filename; qDebug() << "Downloading file: " << u.toString(); this->reply = this->qnam->get(this->request); 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->reply->readAll()); outfile.close(); qDebug() << "Download done."; } void DownloadManager::print() { qDebug() << "The download manager is still working"; } DownloadManager::DownloadManager(const QUrl& baseUrl) { this->qnam = new QNetworkAccessManager(); this->baseUrl = baseUrl; } DownloadManager::~DownloadManager() { }