Resize DownloadModel based on last item

This commit is contained in:
Florian Bruhin 2014-06-13 20:19:00 +02:00
parent ba1f8e3764
commit 6579f4dba0
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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: