def tree_item_clicked(self, item, column): # print(item.text(column)) item_id = self.UI.treeDataSet.get_item_id(item) item_type = self.UI.treeDataSet.get_item_type(item) # Clear all widgets self.clear_main_widgets() if item_type == "group": self.show_group(self.UI.treeDataSet.groups[item_id]) # groupWidget = GroupWindow(dbManager=self.dbMan, group = self.UI.treeDataSet.groups[item_id]) # self.UI.frmMain.layout().addWidget(groupWidget) if item_type == "participant": self.show_participant(self.UI.treeDataSet.participants[item_id]) if item_type == "recordsets" or item_type == "recordset" or item_type == "subrecord": if item_type == "recordsets": part = self.UI.treeDataSet.participants[ self.UI.treeDataSet.get_item_id(item.parent())] records = self.dbMan.get_all_recordsets(part) else: records = [self.UI.treeDataSet.recordsets[item_id]] recordsWidget = RecordsetWindow(manager=self.dbMan, recordset=records) self.UI.frmMain.layout().addWidget(recordsWidget) if item_type == "result": resultWidget = ResultWindow() self.UI.frmMain.layout().addWidget(resultWidget) self.UI.frmMain.update()
def tree_item_clicked(self, item: QTreeWidgetItem, _: int): # print(item.text(column)) item_id = self.UI.treeDataSet.get_item_id(item) item_type = self.UI.treeDataSet.get_item_type(item) # Clear all widgets self.clear_main_widgets() self.UI.btnProcess.setEnabled(False) self.currentRecordsets = [] if item_type == "group": self.show_group(self.UI.treeDataSet.groups[item_id]) # groupWidget = GroupWindow(dbManager=self.dbMan, group = self.UI.treeDataSet.groups[item_id]) # self.UI.frmMain.layout().addWidget(groupWidget) if item_type == "participant": self.show_participant(self.UI.treeDataSet.participants[item_id]) if item_type == "recordsets" or item_type == "recordset" or item_type == "subrecord" or item_type == "date": if item_type == "recordsets": part = self.UI.treeDataSet.participants[ self.UI.treeDataSet.get_item_id(item.parent())] self.currentRecordsets = self.dbMan.get_all_recordsets( participant=part) elif item_type == "date": # Find associated participant id_participant = self.UI.treeDataSet.get_item_id( item.parent().parent()) part = self.UI.treeDataSet.participants[id_participant] search_date = self.UI.treeDataSet.dates[ Treedatawidget.get_date_id(item.text(0), id_participant)] self.currentRecordsets = self.dbMan.get_all_recordsets( participant=part, start_date=search_date) else: self.currentRecordsets = [ self.UI.treeDataSet.recordsets[item_id] ] records_widget = RecordsetWindow(manager=self.dbMan, recordset=self.currentRecordsets, parent=self) # records_widget.setStyleSheet(self.styleSheet() + records_widget.styleSheet()) self.UI.frmMain.layout().addWidget(records_widget) records_widget.dataDisplayRequest.connect( self.UI.treeDataSet.select_item) records_widget.dataUpdateRequest.connect( self.UI.treeDataSet.update_item) self.UI.btnProcess.setEnabled(True) if item_type == "result": result_widget = ResultWindow( manager=self.dbMan, results=self.UI.treeDataSet.results[item_id], parent=self) self.UI.frmMain.layout().addWidget(result_widget) item.setExpanded(True)