42 pageLayout->setColumnStretch(2, 1); |
42 pageLayout->setColumnStretch(2, 1); |
43 |
43 |
44 BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
44 BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
45 |
45 |
46 web = new DataBrowser(this); |
46 web = new DataBrowser(this); |
47 connect(web, SIGNAL(anchorClicked(QUrl)), this, SLOT(install(const QUrl&))); |
47 connect(web, SIGNAL(anchorClicked(QUrl)), this, SLOT(request(const QUrl&))); |
48 web->setOpenLinks(false); |
48 web->setOpenLinks(false); |
49 pageLayout->addWidget(web, 0, 0, 1, 3); |
49 pageLayout->addWidget(web, 0, 0, 1, 3); |
50 |
50 |
51 progressBarsLayout = new QVBoxLayout(this); |
51 progressBarsLayout = new QVBoxLayout(this); |
52 pageLayout->addLayout(progressBarsLayout, 1, 0, 1, 3); |
52 pageLayout->addLayout(progressBarsLayout, 1, 0, 1, 3); |
53 |
53 |
54 fetchList(); |
54 fetchList(); |
55 } |
55 } |
56 |
56 |
57 void PageDataDownload::install(const QUrl &url) |
57 void PageDataDownload::request(const QUrl &url) |
58 { |
58 { |
59 qWarning() << "Download Request" << url.toString(); |
59 if(url.path().endsWith(".zip")) |
60 QString fileName = QFileInfo(url.toString()).fileName(); |
60 { |
61 |
61 qWarning() << "Download Request" << url.toString(); |
62 QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + url.toString())); |
62 QString fileName = QFileInfo(url.toString()).fileName(); |
63 newRequest.setAttribute(QNetworkRequest::User, fileName); |
63 |
64 |
64 QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + url.path())); |
65 QNetworkAccessManager *manager = new QNetworkAccessManager(this); |
65 newRequest.setAttribute(QNetworkRequest::User, fileName); |
66 QNetworkReply *reply = manager->get(newRequest); |
66 |
67 connect(reply, SIGNAL(finished()), this, SLOT(fileDownloaded())); |
67 QNetworkAccessManager *manager = new QNetworkAccessManager(this); |
68 connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); |
68 QNetworkReply *reply = manager->get(newRequest); |
69 |
69 connect(reply, SIGNAL(finished()), this, SLOT(fileDownloaded())); |
70 QProgressBar *progressBar = new QProgressBar(this); |
70 connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); |
71 progressBarsLayout->addWidget(progressBar); |
71 |
72 progressBars.insert(reply, progressBar); |
72 QProgressBar *progressBar = new QProgressBar(this); |
|
73 progressBarsLayout->addWidget(progressBar); |
|
74 progressBars.insert(reply, progressBar); |
|
75 } else |
|
76 { |
|
77 qWarning() << "Page Request" << url.toString(); |
|
78 |
|
79 QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + url.path())); |
|
80 |
|
81 QNetworkAccessManager *manager = new QNetworkAccessManager(this); |
|
82 QNetworkReply *reply = manager->get(newRequest); |
|
83 connect(reply, SIGNAL(finished()), this, SLOT(pageDownloaded())); |
|
84 } |
73 } |
85 } |
74 |
86 |
75 |
87 |
76 void PageDataDownload::pageDownloaded() |
88 void PageDataDownload::pageDownloaded() |
77 { |
89 { |