--- a/WebBrowser/Download/DownloadManager.py Mon Oct 23 19:42:32 2017 +0200 +++ b/WebBrowser/Download/DownloadManager.py Tue Oct 24 19:09:09 2017 +0200 @@ -55,6 +55,8 @@ self.__downloadDirectory = "" self.__loaded = False + self.__rowHeightMultiplier = 1.1 + self.setDownloadDirectory(Preferences.getUI("DownloadPath")) self.downloadsView.setShowGrid(False) @@ -203,24 +205,35 @@ self.activateWindow() self.raise_() - def __addItem(self, itm): + def __addItem(self, itm, append=False): """ Private method to add a download to the list of downloads. - @param itm reference to the download item (DownloadItem) + @param itm reference to the download item + @type DownloadItem + @param append flag indicating to append the item + @type bool """ itm.statusChanged.connect(self.__updateRow) itm.downloadFinished.connect(self.__finished) - row = len(self.__downloads) + # insert at top of window + if append: + row = len(self.__downloads) + else: + row = 0 self.__model.beginInsertRows(QModelIndex(), row, row) - self.__downloads.append(itm) + if append: + self.__downloads.append(itm) + else: + self.__downloads.insert(0, itm) self.__model.endInsertRows() self.downloadsView.setIndexWidget(self.__model.index(row, 0), itm) icon = self.style().standardIcon(QStyle.SP_FileIcon) itm.setIcon(icon) - self.downloadsView.setRowHeight(row, itm.sizeHint().height() * 1.5) + self.downloadsView.setRowHeight( + row, itm.sizeHint().height() * self.__rowHeightMultiplier) # just in case the download finished before the constructor returned self.__updateRow(itm) self.changeOccurred() @@ -248,10 +261,9 @@ icon = self.style().standardIcon(QStyle.SP_FileIcon) itm.setIcon(icon) - oldHeight = self.downloadsView.rowHeight(row) self.downloadsView.setRowHeight( row, - max(oldHeight, itm.minimumSizeHint().height() * 1.5)) + itm.minimumSizeHint().height() * self.__rowHeightMultiplier) remove = False @@ -334,7 +346,7 @@ from .DownloadItem import DownloadItem itm = DownloadItem(parent=self) itm.setData(download) - self.__addItem(itm) + self.__addItem(itm, append=True) self.cleanupButton.setEnabled( (len(self.__downloads) - self.activeDownloads()) > 0)