def editsEditSlot(self, dummytext): """Enable/disable createbutton.""" # dataset name checks dstext = unicode(self.nameedit.text()) dsvalid = utils.validateDatasetName(dstext) dsexists = dstext in self.document.data # check other edit controls method = self.methodGroup.getRadioChecked() if method is self.valueradio: # value editsokay = self.numstepsedit.hasAcceptableInput() elif method is self.parametricradio: # parametric editsokay = (self.tstartedit.hasAcceptableInput() and self.tendedit.hasAcceptableInput() and self.tstepsedit.hasAcceptableInput()) else: # function editsokay = True # we needs some input on the value if len(unicode(self.valueedit.text())) == 0: editsokay = False # hide / show create button depending whether dataset exists self.createbutton.setVisible(not dsexists) self.replacebutton.setVisible(dsexists) # enable buttons if expressions valid enabled = dsvalid and editsokay self.createbutton.setEnabled(enabled) self.replacebutton.setEnabled(enabled)
def setData(self, idx, data, role): """Rename dataset.""" dsnode = self.objFromIndex(idx) newname = unicode(data.toString()) if not utils.validateDatasetName(newname): return False self.doc.applyOperation( document.OperationDatasetRename(dsnode.data[0], newname)) self.emit( qt4.SIGNAL("dataChanged(const QModelIndex &, const QModelIndex &)"), idx, idx) return True
def setData(self, idx, data, role): """Rename dataset.""" dsnode = self.objFromIndex(idx) newname = unicode(data.toString()) if not utils.validateDatasetName(newname) or newname in self.doc.data: return False self.doc.applyOperation( document.OperationDatasetRename(dsnode.data[0], newname)) self.emit( qt4.SIGNAL( "dataChanged(const QModelIndex &, const QModelIndex &)"), idx, idx) return True