Reimplements the :meth:`QAbstractItemModel.setData` method.

        :param index: Index.
        :type index: QModelIndex
        :param value: Value.
        :type value: QVariant
        :param role: Role.
        :type role: int
        :return: Method success.
        :rtype: bool

def setData(self, index, value, role=Qt.EditRole):
        """
        Reimplements the :meth:`QAbstractItemModel.setData` method.

        :param index: Index.
        :type index: QModelIndex
        :param value: Value.
        :type value: QVariant
        :param role: Role.
        :type role: int
        :return: Method success.
        :rtype: bool
        """

        if not index.isValid():
            return False

        node = self.get_node(index)
        if role == Qt.DisplayRole or role == Qt.EditRole:
            value = foundations.strings.to_string(value.toString())
            roles = {Qt.DisplayRole: value, Qt.EditRole: value}
        else:
            roles = {role: value}

        if index.column() == 0:
            if (node and hasattr(node, "roles")):
                node.roles.update(roles)
                node.name = value
        else:
            attribute = self.get_attribute(node, index.column())
            if (attribute and hasattr(attribute, "roles")):
                attribute.roles.update(roles)
                attribute.value = value

        self.dataChanged.emit(index, index)
        return True