def setData(self, index, value, role):
        if not index.isValid():
            return False
        
        ret  = False
        item = self.items[index.row()]
        self.dirty = True

        if index.column() == 0 and role == QtCore.Qt.CheckStateRole:
            item.active = (value == QtCore.Qt.Checked)
            ret = True
        elif role == QtCore.Qt.EditRole:
            if index.column() == 0:
                item.type = value
            elif index.column() == 1:
                item.dtl = value
            elif index.column() == 2:
                item.value = rules.parse_rtk_with_bonus(value)
            elif index.column() == 3:
                item.reason = value
            else:
                ret = False
            ret = True
        else:
            ret = super(ModifiersTableViewModel, self).setData(index, value, role)
        
        if ret:
            print('user change' + str(item.active))
            self.user_change.emit()
        return ret
示例#2
0
 def accept(self):
     # save item
     self.item.type   = self.cb_modifier.itemData( self.cb_modifier.currentIndex() )
     self.item.reason = self.tx_reason.text()
     self.item.dtl    = self.tx_detail.text()
     self.item.value  = rules.parse_rtk_with_bonus(self.tx_value.text())
     super(ModifierDialog, self).accept()