def setNode(self, node, ms): """ shows values/weights in table_mod_values for given node if addNew values/weights are two empty lists otherwise, values/weights are from take from given mod """ self.ms = ms self.node = node # construct mapping scheme tree self.tree_model = MSTreeModel(self.ms) self.ui.tree_ms.setModel(self.tree_model) self.ui.tree_ms.setEnabled(True) indices = self.tree_model.match(self.ui.tree_ms.rootIndex(), Qt.UserRole, self.node, 1) if len(indices) < 1: return index = indices[0] while index <> self.ui.tree_ms.rootIndex(): self.ui.tree_ms.setExpanded(index, True) index = self.tree_model.parent(index) # set node as selected self.ui.tree_ms.selectionModel().select(indices[0], QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) # expand tree from root to node self.ui.tree_ms.setSelectionMode(QAbstractItemView.SingleSelection) # no modfier given # create event handler for selected node self.ui.tree_ms.selectionModel().selectionChanged.connect(self.nodeSelected) self.nodeSelected()
def setMS(self, ms, isBranch=False): """ set mapping scheme to be saved set mapping scheme type as 'single-level' if isBranch=True set to 'multi-level' otherwise """ self.ms_to_save = ms self.ui.tree_ms_view.setModel(MSTreeModel(ms)) self.ui.tree_ms_view.setSelectionMode(QAbstractItemView.NoSelection) self.ui.txt_ms_create_date.setText( datetime.now().strftime("%Y-%m-%d %H:%M")) self.ui.txt_ms_create_date.setReadOnly(True) if isBranch: self.ui.lb_title.setText(get_ui_string("dlg.savems.title.branch")) self.ui.txt_ms_type.setText( get_ui_string("app.mslibrary.user.singlelevel")) else: self.ui.lb_title.setText(get_ui_string("dlg.savems.title.tree")) self.ui.txt_ms_type.setText( get_ui_string("app.mslibrary.user.multilevel")) self.ui.txt_ms_type.setReadOnly(True)