def __init__(self, iface, editorType, directory, parent=None):
super(shapeCSVeditor, self).__init__(parent)
self.iface = iface
self.interpol = interpol()
self.editorType = editorType
self.directory = directory
...
if 'Layer-Options' in self.editorType:
self.tableView.setItemDelegateForColumn(1,confineComboDelegate(self.tableView))
self.tableView.openPersistentEditor(self.tableData.index(row, 1)
...
def __init__(self, parent):
def createEditor(self, parent, option, index):
confiningChoices = ['True','False']
confineCombo.addItems(self.confiningChoices)
confineCombo.currentIndexChanged[int].connect(self.currentIndexChanged)
return confineCombo
def setEditorData(self, editor, index):
editor.blockSignals(True)
try: idxConversion = self.confiningChoices.index(index.model().data(index,Qt.DisplayRole))
except: idxConversion = 0
editor.setCurrentIndex(int(idxConversion))
editor.blockSignals(False)
def setModelData(self, editor, model, index):
model.setData(index, self.confiningChoices[editor.currentIndex()],Qt.EditRole)
@QtCore.pyqtSlot(int)
def currentIndexChanged(self):
self.commitData.emit(self.sender())
class quiteANiceView(QtGui.QDialog, QtGui.QWidget):
def __init__(self, iface, editorType, directory, parent=None):
super(shapeCSVeditor, self).__init__(parent)
self.iface = iface
self.interpol = interpol()
self.editorType = editorType
self.directory = directory
self.tableView = QtGui.QTableView(self)
...
if 'Layer-Options' in self.editorType:
self.tableView.setItemDelegateForColumn(1,confineComboDelegate(self.tableView))
self.tableView.openPersistentEditor(self.tableData.index(row, 1)
...
class confineComboDelegate(QtGui.QItemDelegate):
def __init__(self, parent):
QtGui.QItemDelegate.__init__(self, parent)
def createEditor(self, parent, option, index):
confiningChoices = ['True','False']
confineCombo = QtGui.QComboBox(parent)
confineCombo.addItems(self.confiningChoices)
confineCombo.currentIndexChanged[int].connect(self.currentIndexChanged)
return confineCombo
def setEditorData(self, editor, index):
editor.blockSignals(True)
try: idxConversion = self.confiningChoices.index(index.model().data(index,Qt.DisplayRole))
except: idxConversion = 0
editor.setCurrentIndex(int(idxConversion))
editor.blockSignals(False)
def setModelData(self, editor, model, index):
model.setData(index, self.confiningChoices[editor.currentIndex()],Qt.EditRole)
@QtCore.pyqtSlot(int)
def currentIndexChanged(self):
self.commitData.emit(self.sender())
To copy to clipboard, switch view to plain text mode
Bookmarks