def METHOD_NAME(self, index):
    if not index.isValid():
        return Qt.NoItemFlags
    if index.isValid() and not self.mapToSource(index).isValid():
        return Qt.NoItemFlags  # Qt.ItemIsEnabled
    else:
        return Qt.ItemIsEnabled | Qt.ItemIsSelectable