'Set the thumbnail SVG contents as a string.
When set it also overrides the icon role.'

def setThumbnail(self, thumbnail):

    self.setData(thumbnail, ThumbnailSVGRole)
    import tempfile
    with tempfile.NamedTemporaryFile(prefix='thumbnail', suffix='.svg', delete=False) as f:
        f.write(thumbnail.encode('utf-8'))
        f.flush()
        icon = QIcon(f.name)
        self.setIcon(icon)
