def METHOD_NAME(self, index):
    """Return the item flags for index.
    Override QAbstractItemModel::flags.
    Return: The item flags, or Qt.ItemFlag.NoItemFlags on error.
    """
    if not index.isValid():
        return Qt.ItemFlag.NoItemFlags
    if index.parent().isValid():
        # item
        return (Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
                Qt.ItemFlag.ItemNeverHasChildren)
    else:
        # category
        return Qt.ItemFlag.NoItemFlags