Resize DownloadModel based on last item
This commit is contained in:
parent
ba1f8e3764
commit
6579f4dba0
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user