def METHOD_NAME(
    self,
    index: QModelIndex,
    value: typing.Any,
    role: int = Qt.ItemDataRole.EditRole,
) -> bool:
    if role == Qt.ItemDataRole.CheckStateRole:
        # The item model stores a Qt.CheckState enum value that can be
        # partially checked, but we only use the unchecked and checked
        # to correspond to the layer's visibility.
        # https://doc.qt.io/qt-5/qt.html#CheckState-enum
        self.getItem(index).visible = (
            Qt.CheckState(value) == Qt.CheckState.Checked
        )
    elif role == Qt.ItemDataRole.EditRole:
        self.getItem(index).name = value
        role = Qt.ItemDataRole.DisplayRole
    else:
        return super().METHOD_NAME(index, value, role=role)
    self.dataChanged.emit(index, index, [role])
    return True