def __init__(self, parent, rospack, signal_msg=None): """ @param signal_msg: Signal to carries a system msg that is shown on GUI. @type signal_msg: QtCore.Signal """ super(NodeSelectorWidget, self).__init__() self._parent = parent self.stretch = None self._signal_msg = signal_msg ui_file = os.path.join(rospack.get_path('rqt_reconfigure'), 'resource', 'node_selector.ui') loadUi(ui_file, self) # List of the available nodes. Since the list should be updated over # time and we don't want to create node instance per every update # cycle, This list instance should better be capable of keeping track. self._nodeitems = OrderedDict() # Dictionary. 1st elem is node's GRN name, # 2nd is TreenodeQstdItem instance. # TODO: Needs updated when nodes list updated. # Setup treeview and models self._item_model = TreenodeItemModel() self._rootitem = self._item_model.invisibleRootItem() # QStandardItem self._nodes_previous = None # Calling this method updates the list of the node. # Initially done only once. self._update_nodetree_pernode() # TODO(Isaac): Needs auto-update function enabled, once another # function that updates node tree with maintaining # collapse/expansion state. http://goo.gl/GuwYp can be a # help. self._collapse_button.pressed.connect( self._node_selector_view.collapseAll) self._expand_button.pressed.connect(self._node_selector_view.expandAll) # Filtering preparation. self._proxy_model = FilterChildrenModel(self) self._proxy_model.setDynamicSortFilter(True) self._proxy_model.setSourceModel(self._item_model) self._node_selector_view.setModel(self._proxy_model) self._filterkey_prev = '' # This 1 line is needed to enable horizontal scrollbar. This setting # isn't available in .ui file. # Ref. http://stackoverflow.com/a/6648906/577001 self._node_selector_view.header().setSectionResizeMode( QHeaderView.ResizeToContents) # Setting slot for when user clicks on QTreeView. self.selectionModel = self._node_selector_view.selectionModel() # Note: self.selectionModel.currentChanged doesn't work to deselect # a treenode as expected. Need to use selectionChanged. self.selectionModel.selectionChanged.connect( self._selection_changed_slot)