55 |
55 |
56 self.__iconProvider = None |
56 self.__iconProvider = None |
57 self.__downloads = [] |
57 self.__downloads = [] |
58 self.__downloadDirectory = "" |
58 self.__downloadDirectory = "" |
59 self.__loaded = False |
59 self.__loaded = False |
|
60 |
|
61 self.__rowHeightMultiplier = 1.1 |
60 |
62 |
61 self.setDownloadDirectory(Preferences.getUI("DownloadPath")) |
63 self.setDownloadDirectory(Preferences.getUI("DownloadPath")) |
62 |
64 |
63 self.downloadsView.setShowGrid(False) |
65 self.downloadsView.setShowGrid(False) |
64 self.downloadsView.verticalHeader().hide() |
66 self.downloadsView.verticalHeader().hide() |
218 self.show() |
220 self.show() |
219 |
221 |
220 self.activateWindow() |
222 self.activateWindow() |
221 self.raise_() |
223 self.raise_() |
222 |
224 |
223 def __addItem(self, itm): |
225 def __addItem(self, itm, append=False): |
224 """ |
226 """ |
225 Private method to add a download to the list of downloads. |
227 Private method to add a download to the list of downloads. |
226 |
228 |
227 @param itm reference to the download item (DownloadItem) |
229 @param itm reference to the download item |
|
230 @type DownloadItem |
|
231 @param append flag indicating to append the item |
|
232 @type bool |
228 """ |
233 """ |
229 itm.statusChanged.connect(self.__updateRow) |
234 itm.statusChanged.connect(self.__updateRow) |
230 itm.downloadFinished.connect(self.__finished) |
235 itm.downloadFinished.connect(self.__finished) |
231 |
236 |
232 row = len(self.__downloads) |
237 # insert at top of window |
|
238 if append: |
|
239 row = len(self.__downloads) |
|
240 else: |
|
241 row = 0 |
233 self.__model.beginInsertRows(QModelIndex(), row, row) |
242 self.__model.beginInsertRows(QModelIndex(), row, row) |
234 self.__downloads.append(itm) |
243 if append: |
|
244 self.__downloads.append(itm) |
|
245 else: |
|
246 self.__downloads.insert(0, itm) |
235 self.__model.endInsertRows() |
247 self.__model.endInsertRows() |
236 |
248 |
237 self.downloadsView.setIndexWidget(self.__model.index(row, 0), itm) |
249 self.downloadsView.setIndexWidget(self.__model.index(row, 0), itm) |
238 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
250 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
239 itm.setIcon(icon) |
251 itm.setIcon(icon) |
240 self.downloadsView.setRowHeight(row, itm.sizeHint().height() * 1.5) |
252 self.downloadsView.setRowHeight( |
|
253 row, itm.sizeHint().height() * self.__rowHeightMultiplier) |
241 # just in case the download finished before the constructor returned |
254 # just in case the download finished before the constructor returned |
242 self.__updateRow(itm) |
255 self.__updateRow(itm) |
243 self.changeOccurred() |
256 self.changeOccurred() |
244 self.__updateActiveItemCount() |
257 self.__updateActiveItemCount() |
245 |
258 |
263 icon = self.__iconProvider.icon(QFileInfo(itm.fileName())) |
276 icon = self.__iconProvider.icon(QFileInfo(itm.fileName())) |
264 if icon.isNull(): |
277 if icon.isNull(): |
265 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
278 icon = self.style().standardIcon(QStyle.SP_FileIcon) |
266 itm.setIcon(icon) |
279 itm.setIcon(icon) |
267 |
280 |
268 oldHeight = self.downloadsView.rowHeight(row) |
|
269 self.downloadsView.setRowHeight( |
281 self.downloadsView.setRowHeight( |
270 row, |
282 row, |
271 max(oldHeight, itm.minimumSizeHint().height() * 1.5)) |
283 itm.minimumSizeHint().height() * self.__rowHeightMultiplier) |
272 |
284 |
273 remove = False |
285 remove = False |
274 globalSettings = QWebSettings.globalSettings() |
286 globalSettings = QWebSettings.globalSettings() |
275 if not itm.downloading() and \ |
287 if not itm.downloading() and \ |
276 globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled): |
288 globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled): |
349 if not download[0].isEmpty() and \ |
361 if not download[0].isEmpty() and \ |
350 download[1] != "": |
362 download[1] != "": |
351 from .DownloadItem import DownloadItem |
363 from .DownloadItem import DownloadItem |
352 itm = DownloadItem(parent=self) |
364 itm = DownloadItem(parent=self) |
353 itm.setData(download) |
365 itm.setData(download) |
354 self.__addItem(itm) |
366 self.__addItem(itm, append=True) |
355 self.cleanupButton.setEnabled( |
367 self.cleanupButton.setEnabled( |
356 (len(self.__downloads) - self.activeDownloads()) > 0) |
368 (len(self.__downloads) - self.activeDownloads()) > 0) |
357 |
369 |
358 self.__loaded = True |
370 self.__loaded = True |
359 self.__updateActiveItemCount() |
371 self.__updateActiveItemCount() |