def METHOD_NAME(self):
    ind = self.currentIndex()
    data = self.itemData(ind)
    #if not data.isValid():
    if data is not None:
        try:
            if not data.isValid():
                data = None
            else:
                data = data.toInt()[0]
        except AttributeError:
            pass
    if data is None:
        return self.itemText(ind)
    else:
        return data