comparison demos/browser/downloadmanager.d @ 100:dcd36d8db2da

more porting
author mandel
date Fri, 29 May 2009 11:36:51 +0000
parents 87bb4e622f9e
children 8636c819ce4d
comparison
equal deleted inserted replaced
99:e252fcf214c5 100:dcd36d8db2da
45 import qt.core.QFile; 45 import qt.core.QFile;
46 import qt.core.QTime; 46 import qt.core.QTime;
47 //import qt.core.QMetaEnum; 47 //import qt.core.QMetaEnum;
48 import qt.core.QSettings; 48 import qt.core.QSettings;
49 //import qt.core.QDebug; 49 //import qt.core.QDebug;
50
51 import qt.gui.QDesktopServices; 50 import qt.gui.QDesktopServices;
52 import qt.gui.QFileDialog; 51 import qt.gui.QFileDialog;
53 import qt.gui.QHeaderView; 52 import qt.gui.QHeaderView;
54 import qt.gui.QFileIconProvider; 53 import qt.gui.QFileIconProvider;
55
56 import qt.core.QAbstractListModel; 54 import qt.core.QAbstractListModel;
57
58 import qt.network.QNetworkReply; 55 import qt.network.QNetworkReply;
59 import qt.webkit.QWebSettings; 56 import qt.webkit.QWebSettings;
57
58 import tango.text.convert.Format;
60 59
61 //import math; 60 //import math;
62 import autosaver; 61 import autosaver;
63 import browserapplication; 62 import browserapplication;
64 import networkaccessmanager; 63 import networkaccessmanager;
175 } 174 }
176 } 175 }
177 176
178 void error(QNetworkReply.NetworkError code) 177 void error(QNetworkReply.NetworkError code)
179 { 178 {
180 qDebug() << "DownloadItem::error" << m_reply.errorString() << m_url; 179 qDebug("DownloadItem::error" ~ m_reply.errorString() ~ m_url);
181 downloadInfoLabel.setText(Format(tr("Network Error: {}"), m_reply.errorString())); 180 downloadInfoLabel.setText(Format(tr("Network Error: {}"), m_reply.errorString()));
182 tryAgainButton.setEnabled(true); 181 tryAgainButton.setEnabled(true);
183 tryAgainButton.setVisible(true); 182 tryAgainButton.setVisible(true);
184 } 183 }
185 184
196 updateInfoLabel(); 195 updateInfoLabel();
197 } 196 }
198 197
199 void metaDataChanged() 198 void metaDataChanged()
200 { 199 {
201 qDebug() << "DownloadItem::metaDataChanged: not handled."; 200 qDebug("DownloadItem::metaDataChanged: not handled.");
202 } 201 }
203 202
204 void finished() 203 void finished()
205 { 204 {
206 progressBar.hide(); 205 progressBar.hide();
333 string baseName = info.completeBaseName(); 332 string baseName = info.completeBaseName();
334 string endName = info.suffix(); 333 string endName = info.suffix();
335 334
336 if (baseName.isEmpty()) { 335 if (baseName.isEmpty()) {
337 baseName = "unnamed_download"; 336 baseName = "unnamed_download";
338 qDebug() << "DownloadManager:: downloading unknown file:" << m_url; 337 qDebug("DownloadManager:: downloading unknown file:" ~ m_url);
339 } 338 }
340 string name = directory ~ baseName ~ "." ~ endName; 339 string name = directory ~ baseName ~ "." ~ endName;
341 if (QFile.exists(name)) { 340 if (QFile.exists(name)) {
342 // already exists, don't overwrite 341 // already exists, don't overwrite
343 int i = 1; 342 int i = 1;
446 bool ok; 445 bool ok;
447 int size = header.toInt(&ok); 446 int size = header.toInt(&ok);
448 if (ok && size == 0) 447 if (ok && size == 0)
449 return; 448 return;
450 449
451 qDebug() << "DownloadManager::handleUnsupportedContent" << reply.url() << "requestFileName" << requestFileName; 450 qDebug("DownloadManager::handleUnsupportedContent" ~ reply.url() ~ "requestFileName" ~ requestFileName);
452 DownloadItem item = new DownloadItem(reply, requestFileName, this); 451 DownloadItem item = new DownloadItem(reply, requestFileName, this);
453 addItem(item); 452 addItem(item);
454 } 453 }
455 454
456 void cleanup() 455 void cleanup()