def __init__(self, parent, itemsDict, column): """ Constructor """ QItemDelegate.__init__(self, parent) self.itemsDict = itemsDict self.column = column
def setModelData(self, editor, model, index): """ save data from editor back to model """ if index.column() == 1: model.setData(index, editor.currentText()) else: # use default QItemDelegate.setModelData(self, editor, model, index) if index.column() == 0: self.columnNameChanged.emit()
def setModelData(self, editor, model, index): """ save data from editor back to model """ if index.column() == self.column: model.setData(index, editor.currentText()) else: # use default QItemDelegate.setModelData(self, editor, model, index)
def setEditorData(self, editor, index): """ load data from model to editor """ m = index.model() if index.column() == 1: txt = m.data(index, Qt.DisplayRole) editor.setEditText(txt) else: # use default QItemDelegate.setEditorData(self, editor, index)
def __init__(self, data, options, parent=None): """ Initializes STRTypeDelegate and QItemDelegate. :param spatial_unit: The current spatial unit. :param type: Object :param parent: The parent of the item delegate. :type parent: QWidget """ QItemDelegate.__init__(self, parent) self.data = data self.options = options self._view = parent
def __init__(self, spatial_unit, parent=None): """ Initializes STRTypeDelegate and QItemDelegate. :param spatial_unit: The current spatial unit. :param type: Object :param parent: The parent of the item delegate. :type parent: QWidget """ QItemDelegate.__init__(self, parent) self.curr_profile = current_profile() self.social_tenure = self.curr_profile.social_tenure self.spatial_unit = spatial_unit
def setModelData(self, editor, model, index): """ save data from editor back to model """ if index.column() == self.column: checkedItems = [] for i in range(editor.count()): item = editor.item(i) if item.checkState() == Qt.Checked: checkedItems.append(item.text()) model.setData(index, '{%s}' % ','.join(checkedItems)) else: # use default QItemDelegate.setModelData(self, editor, model, index)
def setEditorData(self, editor, index): """ load data from model to editor """ m = index.model() try: if index.column() == self.column: txt = m.data(index, Qt.DisplayRole) checkList = txt[1:-1].split(',') for i in range(editor.count()): item = editor.item(i) item.setCheckState(Qt.Checked if item.text() in checkList else Qt.Unchecked) else: # use default QItemDelegate.setEditorData(self, editor, index) except: pass
def createEditor(self, parent, option, index): # special combobox for field type if index.column() == 1: cbo = QComboBox(parent) cbo.setEditable(True) cbo.setFrame(False) for item in self.fieldTypes: cbo.addItem(item) return cbo return QItemDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): """ Creates a custom editor to edit value map data """ # special combobox for field type if index.column() == self.column: cbo = QComboBox(parent) for item in self.itemsDict: cbo.addItem(item, self.itemsDict[item]) return cbo return QItemDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): """ Creates a custom editor to edit value relation data """ # special combobox for field type if index.column() == self.column: list = QListWidget(parent) for item in self.itemsDict: listItem = QListWidgetItem(item) listItem.setCheckState(Qt.Unchecked) list.addItem(listItem) return list return QItemDelegate.createEditor(self, parent, option, index)
def __init__(self, parent, functionOwner): QItemDelegate.__init__(self, parent) self.functionOwner = functionOwner
def __init__(self, parent=None): QItemDelegate.__init__(self, parent)
def __init__(self, field_types, parent=None): QItemDelegate.__init__(self, parent) self.fieldTypes = field_types
def __init__(self, parent, itemList, defaultItem = ""): QItemDelegate.__init__(self, parent) self.itemList = itemList self.defaultItem = defaultItem