def _view_dataset(self, index): """ """ try: if index <= 0: # Clear table. self._tableview.clearModel() self._refresh_result_table() else: # envmonlib: dataset = app_framework.ToolboxDatasets().get_dataset_by_index(index - 1) if isinstance(dataset, plankton_core.DatasetTable): self._tableview.setTableModel(dataset) self._refresh_result_table() elif isinstance(dataset, plankton_core.DatasetNode): # Tree dataset must be converted to table dataset before viewing. targetdataset = plankton_core.DatasetTable() dataset.convert_to_table_dataset(targetdataset) # self._tableview.setTableModel(targetdataset) self._refresh_result_table() # # TODO: Remove later. Default alternative used for non toolbox_utils. else: self._tableview.setTableModel(dataset) self._refresh_result_table() # if self._tableview.getTableModel(): self._numberofrows_label.setText('Number of rows: ' + str(self._tableview.getTableModel().get_row_count())) else: self._numberofrows_label.setText('Number of rows: 0') # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _create_and_view_report(self, report): """ """ try: # Reset and redraw before loading new content. self._tableview.setTableModel(self._empty_dataset_table) self._tableview.resetModel() # Model data has changed. self._tableview.resizeColumnsToContents() # Create a list with selected datasets. datasets = [] for rowindex, dataset in enumerate( app_framework.ToolboxDatasets().get_datasets()): item = self._loaded_datasets_model.item(rowindex, 0) if item.checkState() == QtCore.Qt.Checked: datasets.append(dataset) # Preview result. result_table = plankton_core.DatasetTable() report.create_report( datasets, result_table, # show_debug_info = self._debuginfo_checkbox.checkState(), aggregate_rows=self._aggregate_checkbox.isChecked()) # Preview result. self._tableview.setTableModel(result_table) self._tableview.resetModel() # Model data has changed. self._tableview.resizeColumnsToContents() # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _update_dataset_list(self): """ """ try: self._selectdataset_list.clear() self._selectdataset_list.addItems(["<select dataset>"]) for rowindex, dataset in enumerate(app_framework.ToolboxDatasets().get_datasets()): self._selectdataset_list.addItems(['Import-' + str(rowindex + 1)]) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def __init__(self, name, parentwidget): """ """ self._parent = parentwidget # self._lastusedphytowinfilename = '' self._lastuseddirectory = '' self._tableview = None self._tabledataset = None self._report_list = None # Initialize parent. super(CreateReportsActivity, self).__init__(name, parentwidget) # Listen for changes in the toolbox dataset list. app_framework.ToolboxDatasets().datasetListChanged.connect(self.update) # self._empty_dataset_table = plankton_core.DatasetTable()
def _create_content(self): """ """ content = self._create_scrollable_content() contentLayout = QtWidgets.QVBoxLayout() content.setLayout(contentLayout) contentLayout.addLayout(self._content_select_dataset()) contentLayout.addLayout(self._content_result_table()) contentLayout.addWidget(self._content_save_result()) # Listen for changes in the toolbox dataset list. app_framework.ToolboxDatasets().datasetListChanged.connect(self._update_dataset_list) # Allow synch is confusing. Activate again when used in more tools. # (Currently used in the other way, controlled by a checkbox in load_datasets_activity.) # Listen for changes in the toolbox sync. app_framework.AppSync().selected_row_changed.connect(self._set_selected_dataset)
def _update_imported_dataset_list(self): """ """ try: self._loaded_datasets_model.clear() for rowindex, dataset in enumerate(app_framework.ToolboxDatasets().get_datasets()): item = QtGui.QStandardItem('Import-' + str(rowindex + 1) + '. Source: ' + dataset.get_metadata('file_name')) item.setCheckState(QtCore.Qt.Checked) # item.setCheckState(QtCore.Qt.Unchecked) item.setCheckable(True) self._loaded_datasets_model.appendRow(item) # self._loaded_datasets_listview.repaint() ############################################################# # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str(sys._getframe().f_lineno) toolbox_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def content_select_datasets(self): """ """ # Active widgets and connections. # introlabel = app_framework.RichTextQLabel() # introlabel.setText(help_texts.HelpTexts().getText('AnalyseDatasetsTab1_intro')) # self._loaded_datasets_listview = QtWidgets.QListView() # loaded_datasets_listview.setMaximumHeight(80) # view.setMinimumWidth(500) self._loaded_datasets_model = QtGui.QStandardItemModel() self._loaded_datasets_listview.setModel(self._loaded_datasets_model) # Listen for changes in the toolbox dataset list. app_framework.ToolboxDatasets().datasetListChanged.connect(self._update_imported_dataset_list) # self._clearanalysisdata_button = QtWidgets.QPushButton('Clear analysis data') self._clearanalysisdata_button.clicked.connect(self._clear_analysis_data) self._copydatasets_button = QtWidgets.QPushButton('Load marked dataset(s) for analysis') self._copydatasets_button.clicked.connect(self._copy_datasets_for_analysis) # Layout widgets. hbox1 = QtWidgets.QHBoxLayout() hbox1.addWidget(self._clearanalysisdata_button) hbox1.addWidget(self._copydatasets_button) hbox1.addStretch(10) # layout = QtWidgets.QVBoxLayout() # layout.addWidget(introlabel) layout.addWidget(self._loaded_datasets_listview, 10) # layout.addStretch(5) layout.addLayout(hbox1) self.setLayout(layout) # self._loaded_datasets_listview.show() ############################################################# return self