예제 #1
0
    def setData(self, index, value, role=QtCore.Qt.EditRole):
        if not index.isValid():
            LOG.warning('setData not valid: %r %r', index, value)
            return False
        row_index = index.row()
        node = self._node_list[row_index]
        if node is None:
            LOG.warning('node is invalid: %r %r %r', index, value, node)
            return False
        set_attr_func = self.getSetAttrFuncFromIndex(index)
        if not node.editable():
            LOG.warning('setData not editable: %r %r %r', index, value, node)
            return False

        if set_attr_func is not None:
            if role == QtCore.Qt.EditRole:
                set_attr_func(value)

            if role == QtCore.Qt.CheckStateRole:
                index_checkable = self.indexCheckable(index)
                if index_checkable is True:
                    v = converttypes.checkStateToBoolean(value)
                    v = converttypes.booleanToString(v)
                    set_attr_func(v)

        # Changing some data will force entire row to update.
        columnCount = self.columnCount()
        index_begin = self.createIndex(row_index, 0, index.internalId)
        index_end = self.createIndex(row_index, columnCount - 1,
                                     index.internalId)

        # Emit Data Changed.
        if Qt.__binding__ in ['PySide', 'PyQt4']:
            self.dataChanged.emit(index_begin, index_end)
        elif Qt.__binding__ in ['PySide2', 'PyQt5']:
            self.dataChanged.emit(index_begin, index_end, [role])
        else:
            msg = 'Qt binding not supported: %s' % Qt.__binding__
            raise ValueError(msg)
        return True
예제 #2
0
 def stepEnabled(self):
     n = self.stepNode()
     if n is None:
         return 'False'
     v = n.get_enabled()
     return converttypes.booleanToString(v)
예제 #3
0
 def stepEnabled(self):
     n = self.stepNode()
     v = n.get_enabled()
     return converttypes.booleanToString(v)