65 self.__page = webPage |
65 self.__page = webPage |
66 self.__toDownload = download |
66 self.__toDownload = download |
67 self.__bytesReceived = 0 |
67 self.__bytesReceived = 0 |
68 self.__downloadTime = QTime() |
68 self.__downloadTime = QTime() |
69 self.__output = QFile() |
69 self.__output = QFile() |
|
70 self.__initialized = False |
70 |
71 |
71 def initialize(self): |
72 def initialize(self): |
72 """ |
73 """ |
73 Public method to (re)initialize the dialog. |
74 Public method to (re)initialize the dialog. |
74 |
75 |
79 |
80 |
80 self.__startedSaving = False |
81 self.__startedSaving = False |
81 self.__downloadFinished = False |
82 self.__downloadFinished = False |
82 |
83 |
83 self.__url = self.__reply.url() |
84 self.__url = self.__reply.url() |
|
85 if not self.__getFileName(): |
|
86 return False |
|
87 |
84 self.__reply.setParent(self) |
88 self.__reply.setParent(self) |
85 self.connect(self.__reply, SIGNAL("readyRead()"), self.__readyRead) |
89 self.connect(self.__reply, SIGNAL("readyRead()"), self.__readyRead) |
86 self.connect(self.__reply, SIGNAL("error(QNetworkReply::NetworkError)"), |
90 self.connect(self.__reply, SIGNAL("error(QNetworkReply::NetworkError)"), |
87 self.__networkError) |
91 self.__networkError) |
88 self.connect(self.__reply, SIGNAL("downloadProgress(qint64, qint64)"), |
92 self.connect(self.__reply, SIGNAL("downloadProgress(qint64, qint64)"), |
92 self.connect(self.__reply, SIGNAL("finished()"), self.__finished) |
96 self.connect(self.__reply, SIGNAL("finished()"), self.__finished) |
93 |
97 |
94 # reset info |
98 # reset info |
95 self.infoLabel.clear() |
99 self.infoLabel.clear() |
96 self.progressBar.setValue(0) |
100 self.progressBar.setValue(0) |
97 if not self.__getFileName(): |
|
98 return False |
|
99 |
101 |
100 # start timer for the download estimation |
102 # start timer for the download estimation |
101 self.__downloadTime.start() |
103 self.__downloadTime.start() |
|
104 |
|
105 self.__initialized = True |
102 |
106 |
103 if self.__reply.error() != QNetworkReply.NoError: |
107 if self.__reply.error() != QNetworkReply.NoError: |
104 self.__networkError() |
108 self.__networkError() |
105 self.__finished() |
109 self.__finished() |
106 return False |
110 return False |
421 |
425 |
422 def closeEvent(self, evt): |
426 def closeEvent(self, evt): |
423 """ |
427 """ |
424 Protected method called when the dialog is closed. |
428 Protected method called when the dialog is closed. |
425 """ |
429 """ |
426 self.__output.close() |
430 if self.__initialized: |
427 |
431 self.__output.close() |
428 self.disconnect(self.__reply, SIGNAL("readyRead()"), self.__readyRead) |
432 |
429 self.disconnect(self.__reply, SIGNAL("error(QNetworkReply::NetworkError)"), |
433 self.disconnect(self.__reply, SIGNAL("readyRead()"), self.__readyRead) |
430 self.__networkError) |
434 self.disconnect(self.__reply, SIGNAL("error(QNetworkReply::NetworkError)"), |
431 self.disconnect(self.__reply, SIGNAL("downloadProgress(qint64, qint64)"), |
435 self.__networkError) |
432 self.__downloadProgress) |
436 self.disconnect(self.__reply, SIGNAL("downloadProgress(qint64, qint64)"), |
433 self.disconnect(self.__reply, SIGNAL("metaDataChanged()"), |
437 self.__downloadProgress) |
434 self.__metaDataChanged) |
438 self.disconnect(self.__reply, SIGNAL("metaDataChanged()"), |
435 self.disconnect(self.__reply, SIGNAL("finished()"), self.__finished) |
439 self.__metaDataChanged) |
436 self.__reply.close() |
440 self.disconnect(self.__reply, SIGNAL("finished()"), self.__finished) |
437 self.__reply.deleteLater() |
441 self.__reply.close() |
438 |
442 self.__reply.deleteLater() |
439 self.done.emit() |
443 |
|
444 self.done.emit() |