def __init__(self, parent, id, dataSet): super(DataBrowser, self).__init__(parent) self.setupUi(self) self._simWorkbench = None self.dataService = None self.id = id self.data = dataSet self.optionsService = OptionsService() # create the custom selectable table header self.selectableHeader = SelectableTableHeader(Qt.Horizontal, self.tableView) self.selectableHeader.setNonSelectableIndexes([0]) self.selectableHeader.sectionSelectionChanged.connect( self.on_columnSelectionChanged) self.tableView.setHorizontalHeader(self.selectableHeader) # create the data model self.dataModel = DataBrowserModel(self, self.id, self.data) self.tableView.setModel(self.dataModel) self._setUpSelectionCheckBox() self._updateInfoPane() if not self.optionsService.getDebug(): self.groupBoxPerturbation.setVisible(False)
def updateDataSources(self, dataSources, dataID=None): """ Gets the data files that were produced by the last integration run and invokes updating the data source table and the data tabs (plot/table). The data structure for the data model is a dict: {'source ID': [list of data IDs, e.g. GnrH, ...]} """ self.dataSources = dataSources if not self.dataSources: logging.info("No data sources, nothing to be shown.") return logging.info("Updating data sources...") self.dataSourceIDs = [] if type(self.dataSources) is list: try: combinedDataSource = OrderedDict() for source in self.dataSources: for key, value in source.items(): if not value.isSelected(): continue origin = value.getId() if not origin in self.dataSourceIDs: self.dataSourceIDs.append(origin) if key in combinedDataSource: logging.debug("AbstractViewController: Duplicate key encountered while merging data sources for display.") combinedDataSource[key] = value self.dataSources = combinedDataSource except: logging.error("AbstractViewController: Could not combine several datasource dictionaries into one.") if dataID: singledataSource = OrderedDict() singledataSource[dataID] = self.dataSources[dataID] self.dataSources = singledataSource if self.dataSourceTableModel: self.dataSourceTableModel.dataChanged.disconnect(self.on_dataSourcesChanged) self.dataSourceTableModel = DataSourcesTableModel(self.dataSources) self.dataSourceTableView.setModel(self.dataSourceTableModel) # use header with checkboxes selectableTableHeaderHorizontal = SelectableTableHeader(Qt.Horizontal, self.dataSourceTableView) selectableTableHeaderHorizontal.setNonSelectableIndexes([0]) selectableTableHeaderHorizontal.sectionSelectionChanged.connect(self.on_columnSelectionChanged) # selectableTableHeaderHorizontal.connectSelectionModel(self.dataSourceTableModel) self.dataSourceTableView.setHorizontalHeader(selectableTableHeaderHorizontal) selectableTableHeaderVertical = SelectableTableHeader(Qt.Vertical, self.dataSourceTableView) selectableTableHeaderVertical.sectionSelectionChanged.connect(self.on_rowSelectionChanged) # selectableTableHeaderVertical.connectSelectionModel(self.dataSourceTableModel) self.dataSourceTableView.setVerticalHeader(selectableTableHeaderVertical) self.dataSourceTableView.resizeColumnsToContents() self.dataSourceTableModel.dataChanged.connect(self.on_dataSourcesChanged) self.on_dataSourcesChanged(None, None)