'Override sizeHint of QStyledItemDelegate.
Return the cell size based on the QTextDocument size, but might not
work correctly yet.
Args:
option: const QStyleOptionViewItem & option
index: const QModelIndex & index
Return:
A QSize with the recommended size.'

def sizeHint(self, option, index):

    value = index.data(Qt.SizeHintRole)
    if (value is not None):
        return value
    self._opt = QStyleOptionViewItem(option)
    self.initStyleOption(self._opt, index)
    self._style = self._opt.widget.style()
    self._get_textdoc(index)
    docsize = self._doc.size().toSize()
    size = self._style.sizeFromContents(QStyle.CT_ItemViewItem, self._opt, docsize, self._opt.widget)
    qtutils.ensure_valid(size)
    return (size + QSize(10, 3))
