def fill_edits(self, dummy1='', dummy2=''): self.enable_edits() wl = self._widgets line = self.treeWraper.getCurrentItemLine() wl.depNameEdit.setText(line['name']) wl.depSIDEdit.setText(line['sid']) wl.depDescriptionEdit.setText(line['description']) wl.disabledRolesList.clear() if line['id'] == '': return try: dep_roles = Query.select('GET_DEP_DISABLED_ROLES', department_id=line['id']) except Exception, err: self.errorMessage(err)
def onInit(self, **kparams): self.setupForm(Ui_Form) QtCore.QObject.connect(self._widgets.insertButton, QtCore.SIGNAL("clicked ()"), self.onInsert) QtCore.QObject.connect(self._widgets.modifyButton, QtCore.SIGNAL("clicked ()"), self.onModify) QtCore.QObject.connect(self._widgets.deleteButton, QtCore.SIGNAL("clicked ()"), self.onDelete) self.departaments = {} data = Query.select('get_departaments') for item in data: treeItem = QtGui.QTreeWidgetItem() if not item.description: item.description = '' treeItem.setText(0, str(item.name)) treeItem.setText(1, str(item.description)) self.departaments[item.id] = treeItem top_levels = [] for item in data: chItem = self.departaments[item.id] if not item.parent_id: top_levels.append(chItem) continue parItem = self.departaments.get(item.parent_id, None) if not parItem: raise Exception (self.tr('Departament parent ( %s ) is not found!'%item.parent_id)) parItem.addChild(chItem) self._widgets.treeWidget.insertTopLevelItems(0, top_levels) for item in top_levels: self._widgets.treeWidget.expandItem(top_levels[0])
def onInit(self, **kparams): self.setupForm(Ui_departments) self.mgt_interface = Client.get_interface('FABLIK_MGT') self.syncTree() self._widgets.departmentsTree.setColumnWidth(0, 250) self._widgets.departmentsTree.setColumnWidth(1, 150) self.disable_edits() self._widgets.allRolesList.clear() self.all_roles = Query.select('GET_ROLES') for role in self.all_roles: self._widgets.allRolesList.addItem(role['sid']) #connect signals self._widgets.newDepBtn.clicked.connect(self.onCreateNewDepartment) self._widgets.newSubDepBtn.clicked.connect(self.onCreateSubDepartment) self._widgets.remDepBtn.clicked.connect(self.onRemoveDepartment) self._widgets.applyBtn.clicked.connect(self.onApplyDepartment) self._widgets.departmentsTree.itemSelectionChanged.connect(self.fill_edits)