diff --git a/qutebrowser/models/downloadmodel.py b/qutebrowser/models/downloadmodel.py index b9ba5027e..a5cca560d 100644 --- a/qutebrowser/models/downloadmodel.py +++ b/qutebrowser/models/downloadmodel.py @@ -53,6 +53,10 @@ class DownloadModel(QAbstractListModel): model_idx = self.index(idx, 0) self.dataChanged.emit(model_idx, model_idx) + def last_index(self): + """Get the last index in the model.""" + return self.index(self.rowCount() - 1) + def headerData(self, section, orientation, role): """Simple constant header.""" if (section == 0 and orientation == Qt.Horizontal and diff --git a/qutebrowser/widgets/downloads.py b/qutebrowser/widgets/downloads.py index 322699bc7..ef41852d7 100644 --- a/qutebrowser/widgets/downloads.py +++ b/qutebrowser/widgets/downloads.py @@ -72,7 +72,8 @@ class DownloadView(QListView): def sizeHint(self): """Return sizeHint based on the view contents.""" - height = self.sizeHintForRow(0) + idx = self.model().last_index() + height = self.visualRect(idx).bottom() if height != -1: return QSize(0, height + 2) else: