def initialize(self, layer, feature, db, mode = 0, onlyInitializeN2m = False): DdN2mWidget.initialize(self, layer, feature, db, mode) if feature != None and not onlyInitializeN2m: self.initializeTableLayer(db, doShowParents = False, withMask = True, skip = [self.attribute.relationRelatedIdField]) self.relatedLayer = self.loadAdditionalLayer(db, self.attribute.relatedTable) for i in range(len(self.attribute.attributes)): anAttr = self.attribute.attributes[i] if anAttr.name == self.attribute.relationRelatedIdField: self.relationRelatedIdIndex = i break if self.hasCatalog(): self.catalogLayer = self.loadAdditionalLayer(db, self.attribute.catalogTable) self.fillCatalog(self.catalogIndex) else: self.fill()
def setupUi(self, parent, db): if self.hasCatalog(): frame = QtGui.QFrame(parent) frame.setFrameShape(QtGui.QFrame.StyledPanel) frame.setFrameShadow(QtGui.QFrame.Raised) frame.setObjectName("frame" + parent.objectName() + self.attribute.name) label = self.createLabel(frame) self.inputWidget = self.createInputWidget(frame) self.setSizeMax(frame) self.inputWidget.setToolTip(self.attribute.comment) verticalLayout = QtGui.QVBoxLayout(frame) verticalLayout.setObjectName("vlayout" + parent.objectName() + self.attribute.name) verticalLayout.addWidget(label) formLayout = QtGui.QFormLayout( ) formLayout.setObjectName("formlayout" + parent.objectName() + self.attribute.name) #spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.catalogCbx = QtGui.QComboBox(frame) self.catalogCbx.setObjectName("cbx" + parent.objectName() + self.attribute.catalogTable.tableName) self.catalogCbx.setToolTip(self.attribute.catalogTable.comment) #self.catalogCbx.setEditable(True) self.catalogCbx.currentIndexChanged.connect(self.catalogChanged) cbxLabel = QtGui.QLabel(self.attribute.catalogLabel, frame) cbxLabel.setObjectName("lbl" + parent.objectName() + self.attribute.catalogTable.tableName) formLayout.addRow(cbxLabel, self.catalogCbx) verticalLayout.addLayout(formLayout) verticalLayout.addWidget(self.inputWidget) newRow = parent.layout().rowCount() + 1 parent.layout().setWidget(newRow, QtGui.QFormLayout.SpanningRole, frame) pParent = parent while (True): pParent = pParent.parentWidget() if isinstance(pParent, DdDialog) or isinstance(pParent, DdSearchDialog): self.parentDialog = pParent break else: DdN2mWidget.setupUi(self, parent, db)
def __init__(self, attribute): DdN2mWidget.__init__(self, attribute) self.catalogCbx = None self.catalogLayer = None self.catalogIndex = 0