'Return sizeHint based on the view contents.'

def sizeHint(self):

    idx = self.model().last_index()
    bottom = self.visualRect(idx).bottom()
    if (bottom != (-1)):
        margins = self.contentsMargins()
        height = (((bottom + margins.top()) + margins.bottom()) + (2 * self.spacing()))
        size = QSize(0, height)
    else:
        size = QSize(0, 0)
    qtutils.ensure_valid(size)
    return size
