def __init__(self, parent, afefuc, item=None): self.parent = parent self.dialog = QtGui.QDialog() self.form = Ui_BusinessObjectForm() self.afefuc = afefuc self.item = item[1] self.item_orginal = item[0]
def __init__(self, parent, afefuc, item = None): self.parent = parent self.dialog = QtGui.QDialog() self.form = Ui_BusinessObjectForm() self.afefuc = afefuc self.item = item[1] self.item_orginal = item[0]
class BusinessObjectFormWrapper(): def __init__(self, parent, afefuc, item=None): self.parent = parent self.dialog = QtGui.QDialog() self.form = Ui_BusinessObjectForm() self.afefuc = afefuc self.item = item[1] self.item_orginal = item[0] def load(self): self.form.nameEdit.setText( _fromUtf8(converter.itemsToText(self.item.name, edit=True))) self.form.idEdit.setText(_fromUtf8(self.item.identifier)) self.form.descriptionEdit.setPlainText( _fromUtf8(converter.itemsToText(self.item.description, edit=True))) self.form.stateDiagramEdit.setPlainText( _fromUtf8(self.item.state_diagram)) def show(self): self.form.setupUi(self.dialog) self.model = AttributesTableModel(self.form.attributesView, self.afefuc, self.item) self.form.attributesView.setModel(self.model) self.form.attributesView.setItemDelegateForColumn( 1, ComboBoxDelegate(self.form.attributesView, self.item)) #self.form.attributesView.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents) self.form.attributesView.horizontalHeader().setResizeMode( 2, QtGui.QHeaderView.Stretch) #self.form.attributesView.horizontalHeader().hide() self.form.attributesView.verticalHeader().hide() self.form.attributesView.setEditTriggers( QtGui.QAbstractItemView.CurrentChanged) self.load() QtCore.QObject.connect(self.form.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedAddButton) QtCore.QObject.connect(self.form.deleteButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedDeleteButton) QtCore.QObject.connect(self.form.moveUpButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveUpButton) QtCore.QObject.connect(self.form.moveDownButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveDownButton) QtCore.QObject.connect(self.form.boxButton, QtCore.SIGNAL(_fromUtf8("accepted()")), self.clickedOKButton) QtCore.QObject.connect(self.form.boxButton, QtCore.SIGNAL(_fromUtf8("rejected()")), self.clickedCancelButton) self.dialog.exec_() def clickedCancelButton(self): self.dialog.close() def clickedOKButton(self): try: self.item.name = converter.textToItems( self.afefuc['project'], unicode(self.form.nameEdit.text().toUtf8(), "utf-8")) except ValueError: validation.errorMessage(self.dialog, "Invalid reference in name") return self.item.identifier = unicode(self.form.idEdit.text().toUtf8(), "utf-8") try: self.item.description = converter.textToItems( self.afefuc['project'], unicode(self.form.descriptionEdit.toPlainText().toUtf8(), "utf-8")) except ValueError: validation.errorMessage(self.dialog, "Invalid reference in description") return self.item.state_diagram = unicode( self.form.stateDiagramEdit.toPlainText().toUtf8(), "utf-8") # validate errors = validation.business_object(self.afefuc['project'], self.item, self.item_orginal is None) if errors: validation._show(self.dialog, errors) return if self.item_orginal: self.parent.model.updateItem((self.item_orginal, self.item)) else: self.parent.model.insertItem((self.item_orginal, self.item)) self.dialog.close() def clickedAddButton(self): attribute = model.Attribute() attribute.type = model.AttributeType.SUPPLEMENTARY self.model.insertItem(attribute) def clickedDeleteButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.removeItem(position) def clickedMoveUpButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.movePositionUp(position) def clickedMoveDownButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.movePositionDown(position)
class BusinessObjectFormWrapper(): def __init__(self, parent, afefuc, item = None): self.parent = parent self.dialog = QtGui.QDialog() self.form = Ui_BusinessObjectForm() self.afefuc = afefuc self.item = item[1] self.item_orginal = item[0] def load(self): self.form.nameEdit.setText(_fromUtf8(converter.itemsToText(self.item.name, edit = True))) self.form.idEdit.setText(_fromUtf8(self.item.identifier)) self.form.descriptionEdit.setPlainText(_fromUtf8(converter.itemsToText(self.item.description, edit = True))) self.form.stateDiagramEdit.setPlainText(_fromUtf8(self.item.state_diagram)) def show(self): self.form.setupUi(self.dialog) self.model = AttributesTableModel(self.form.attributesView, self.afefuc, self.item) self.form.attributesView.setModel(self.model) self.form.attributesView.setItemDelegateForColumn(1, ComboBoxDelegate(self.form.attributesView, self.item)) #self.form.attributesView.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents) self.form.attributesView.horizontalHeader().setResizeMode(2, QtGui.QHeaderView.Stretch) #self.form.attributesView.horizontalHeader().hide() self.form.attributesView.verticalHeader().hide() self.form.attributesView.setEditTriggers(QtGui.QAbstractItemView.CurrentChanged) self.load() QtCore.QObject.connect(self.form.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedAddButton) QtCore.QObject.connect(self.form.deleteButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedDeleteButton) QtCore.QObject.connect(self.form.moveUpButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveUpButton) QtCore.QObject.connect(self.form.moveDownButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveDownButton) QtCore.QObject.connect(self.form.boxButton, QtCore.SIGNAL(_fromUtf8("accepted()")), self.clickedOKButton) QtCore.QObject.connect(self.form.boxButton, QtCore.SIGNAL(_fromUtf8("rejected()")), self.clickedCancelButton) self.dialog.exec_() def clickedCancelButton(self): self.dialog.close() def clickedOKButton(self): try: self.item.name = converter.textToItems( self.afefuc['project'], unicode(self.form.nameEdit.text().toUtf8(), "utf-8") ) except ValueError: validation.errorMessage(self.dialog, "Invalid reference in name") return self.item.identifier = unicode(self.form.idEdit.text().toUtf8(), "utf-8") try: self.item.description = converter.textToItems( self.afefuc['project'], unicode(self.form.descriptionEdit.toPlainText().toUtf8(), "utf-8") ) except ValueError: validation.errorMessage(self.dialog, "Invalid reference in description") return self.item.state_diagram = unicode(self.form.stateDiagramEdit.toPlainText().toUtf8(), "utf-8") # validate errors = validation.business_object(self.afefuc['project'], self.item, self.item_orginal is None) if errors: validation._show(self.dialog, errors) return if self.item_orginal: self.parent.model.updateItem((self.item_orginal, self.item)) else: self.parent.model.insertItem((self.item_orginal, self.item)) self.dialog.close() def clickedAddButton(self): attribute = model.Attribute() attribute.type = model.AttributeType.SUPPLEMENTARY self.model.insertItem(attribute) def clickedDeleteButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.removeItem(position) def clickedMoveUpButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.movePositionUp(position) def clickedMoveDownButton(self): if len(self.form.attributesView.selectedIndexes()) == 1: position = self.form.attributesView.selectedIndexes()[0].row() self.model.movePositionDown(position)