summaryrefslogtreecommitdiffstats
path: root/src/downloadmanager.cpp
blob: bfaf22ac9caded992b6d8d9366f298004cabdde5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "downloadmanager.h"

void DownloadManager::downloadFile(QString& filename)
{
	this->filename = filename;
	this->reply = this->qnam->get(this->request);
	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->reply->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();
	this->request.setUrl(baseUrl);
}

DownloadManager::~DownloadManager()
{
}