<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setData(self, index, value, role=Qt.EditRole):
 """ Set the data for the item at the given index to the given value. """

        item = self.itemAt(index)
        if not item:
            return False
        d = item.declaration
        if role == Qt.CheckStateRole:
            checked = value == Qt.Checked
            if checked != d.checked:
                d.checked = checked
                d.toggled(checked)
            return True
        elif role == Qt.EditRole:
            if value != d.text:
                d.text = value
            return True
        return super(QAbstractAtomItemModel, self).setData(index, value, role)