35 from __future__
import division
37 from python_qt_binding.QtCore
import Qt, Signal
39 from python_qt_binding.QtCore
import QSortFilterProxyModel
41 from python_qt_binding.QtGui
import QSortFilterProxyModel
43 from rqt_reconfigure
import logging
49 Extending QSortFilterProxyModel, this provides methods to filter children 52 QSortFilterProxyModel filters top-down direction starting from the 53 top-level of tree, and once a node doesn't hit the query it gets disabled. 54 Filtering with this class reflects the result from the bottom node. 57 #TODO example needed here 62 sig_filtered = Signal(int)
65 super(FilterChildrenModel, self).
__init__(parent)
79 "Treenode" is deliberately used to avoid confusion with "Node" in ROS. 82 :type src_parent_qmindex: QModelIndex 84 logging.debug(
'filerAcceptRow 1')
90 :type src_parent_qmindex: QModelIndex 92 _src_model = self.sourceModel()
93 curr_qmindex = _src_model.index(src_row, 0, src_parent_qmindex)
94 curr_qitem = _src_model.itemFromIndex(curr_qmindex)
96 if isinstance(curr_qitem, TreenodeQstdItem):
98 nodename_fullpath = curr_qitem.get_raw_param_name()
99 text_filter_target = nodename_fullpath
100 logging.debug(
' Nodename full={} '.format(nodename_fullpath))
104 text_filter_target = curr_qitem.data(Qt.DisplayRole)
106 regex = self.filterRegExp()
107 pos_hit = regex.indexIn(text_filter_target)
109 logging.debug(
'curr data={} row={} col={}'.format(
110 curr_qmindex.data(), curr_qmindex.row(), curr_qmindex.column()
115 ' FCModel.filterAcceptsRow' 116 ' src_row={} parent row={} data={} filterRegExp={}'.format(
117 src_row, src_parent_qmindex.row(),
118 src_parent_qmindex.data(), regex))
122 _child_index = curr_qmindex.child(0, 0)
123 if ((
not _child_index.isValid())
and 124 (isinstance(curr_qitem, TreenodeQstdItem))):
133 if not isinstance(curr_qitem, TreenodeQstdItem):
139 child_qmindex = curr_qmindex.child(row_child, 0)
140 if child_qmindex.isValid():
151 :type curr_qitem: QStandardItem 153 logging.debug(
'_show_params_view data={}'.format(
154 curr_qitem.data(Qt.DisplayRole)
156 curr_qitem.enable_param_items()
161 self._get_toplevel_parent(p)
168 Doing nothing really since columns are not in use. 170 :type source_column: int 171 :type source_parent: QModelIndex 173 logging.debug(
'FCModel.filterAcceptsCol source_col={} '.format(
174 source_column) +
'parent col={} row={} data={}'.format(
175 source_parent.column(), source_parent.row(),
176 source_parent.data()))
184 if filter_.get_text ==
'':
186 logging.info(
'filter invalidated.')
189 self.setFilterRegExp(self._filter.get_regexp())