def _update_output_nodes(self, is_node_running, node_name): """ Slot for signals that tell nodes existence. @type is_node_running: bool @type node_name: str """ #TODO: What this method does is exactly the same with # monitor_parameters. Unify them. rospy.logdebug('is_node_running={} par_name={}'.format( is_node_running, node_name)) node_name = str(node_name) node_qitem = None if not node_name in self._node_qitems: node_qitem = QStandardItem(node_name) self._node_qitems[node_name] = node_qitem self._node_datamodel.appendRow(node_qitem) else: # qsitem with the node name already exists. node_qitem = self._node_qitems[str(node_name)] qindex = self._node_datamodel.indexFromItem(node_qitem) _str_node_running = 'Not running' if is_node_running: _str_node_running = 'Running' qitem_node_status = QStandardItem(_str_node_running) self._node_datamodel.setItem(qindex.row(), 1, qitem_node_status)
def __init__(self, name, path, lid, parent=None): ''' Initialize the topic item. @param name: the topic name @type name: C{str} ''' QStandardItem.__init__(self, name) self.parent_item = parent self.name = name self.path = path self.package_name = package_name(os.path.dirname(self.path))[0] self.id = lid if self.id == LaunchItem.FOLDER: self.setIcon(QIcon(":/icons/crystal_clear_folder.png")) elif self.id == LaunchItem.PACKAGE: self.setIcon(QIcon(":/icons/crystal_clear_package.png")) elif self.id == LaunchItem.LAUNCH_FILE: self.setIcon(QIcon(":/icons/crystal_clear_launch_file.png")) elif self.id == LaunchItem.RECENT_FILE: self.setIcon(QIcon(":/icons/crystal_clear_launch_file_recent.png")) elif self.id == LaunchItem.STACK: self.setIcon(QIcon(":/icons/crystal_clear_stack.png")) elif self.id == LaunchItem.PROFILE: self.setIcon(QIcon(":/icons/crystal_clear_profile.png")) elif self.id == LaunchItem.RECENT_PROFILE: self.setIcon(QIcon(":/icons/crystal_clear_profile_recent.png"))
def _update_output_parameters(self, has_param, param_name): """ Slot @type has_param: bool @type param_name: str """ rospy.logdebug('has_param={} par_name={}'.format( has_param, param_name)) param_name = str(param_name) param_qitem = None if not param_name in self._param_qitems: param_qitem = QStandardItem(param_name) self._param_qitems[param_name] = param_qitem self._param_datamodel.appendRow(param_qitem) else: # qsitem with the param name already exists. param_qitem = self._param_qitems[str(param_name)] qindex = self._param_datamodel.indexFromItem(param_qitem) _str_param_found = 'No' if has_param: _str_param_found = 'Yes' qitem_param_status = QStandardItem(_str_param_found) self._param_datamodel.setItem(qindex.row(), 1, qitem_param_status) self._view_params.resizeColumnsToContents()
def _get_data_items_for_path(self, slot_name, slot_type, slot_path, **kwargs): expression_item = QStandardItem('') expression_item.setToolTip( 'enter valid Python expression here, using "i" as counter and functions from math, random and time modules' ) return (ReadonlyItem(slot_name), ReadonlyItem(QStandardItem(slot_type)), expression_item)
def __init__(self, service, parent=None): ''' Initialize the service item. @param service: the service object to view @type service: U{master_discovery_fkie.ServiceInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.ServiceInfo>} ''' QStandardItem.__init__(self, service.name) self.service = service '''@ivar: service info as U{master_discovery_fkie.ServiceInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.ServiceInfo>}.'''
def __init__(self, service, parent=None): ''' Initialize the service item. @param service: the service object to view @type service: L{master_discovery_fkie.ServiceInfo} ''' QStandardItem.__init__(self, service.name) self.service = service '''@ivar: service info as L{master_discovery_fkie.ServiceInfo}.'''
def _refill_tree(self, included_from, includes, create_tree=True): deep = 0 file_dsrc = self._root_path try: file_dsrc = os.path.basename(self._root_path) except Exception: pass self.setWindowTitle("Include Graph - %s" % file_dsrc) if not self._created_tree and create_tree: with CHACHE_MUTEX: if self._root_path in GRAPH_CACHE: pkg, _ = package_name(os.path.dirname(self._root_path)) itemstr = '%s [%s]' % (os.path.basename(self._root_path), pkg) inc_item = QStandardItem('%s' % itemstr) inc_item.setData(self._root_path, self.DATA_FILE) inc_item.setData(-1, self.DATA_LINE) inc_item.setData(self._root_path, self.DATA_INC_FILE) inc_item.setData(deep, self.DATA_LEVEL) self._append_items(inc_item, deep + 1) self.graphTreeView.model().appendRow(inc_item) # self.graphTreeView.expand(self.graphTreeView.model().indexFromItem(inc_item)) self._created_tree = True items = self.graphTreeView.model().match(self.graphTreeView.model().index(0, 0), self.DATA_INC_FILE, self._current_path, 10, Qt.MatchRecursive) first = True self.graphTreeView.selectionModel().clearSelection() for item in items: if first: self._current_deep = item.data(self.DATA_LEVEL) self.graphTreeView.selectionModel().select(item, QItemSelectionModel.SelectCurrent) first = False else: self.graphTreeView.selectionModel().select(item, QItemSelectionModel.Select) self.graphTreeView.expandAll()
def __init__(self, name, topic=None, parent=None): ''' Initialize the topic item. @param name: the topic name @type name: C{str} ''' QStandardItem.__init__(self, name) self.parent_item = parent '''@ivar: service info as L{master_discovery_fkie.ServiceInfo}.''' self._publish_thread = None self.topic = TopicInfo(name) if topic is None else topic
def __init__(self, rapp, running): QStandardItem.__init__(self, rapp['display_name']) self.setSizeHint(QSize(100,100)) icon = get_qicon(rapp['icon']) self.setIcon(icon) f = QFont() f.setPointSize(10) self.setFont(f) self.setToolTip(rapp['description']) self.setEditable(False) self.setRapp(rapp) self.setEnabled(running)
def __init__(self, service, parent=None): ''' Initialize the service item. :param service: the service object to view :type service: fkie_master_discovery.ServiceInfo<http://docs.ros.org/kinetic/api/fkie_master_discovery/html/modules.html#fkie_master_discovery.master_info.ServiceInfo> ''' QStandardItem.__init__(self, service.name) self._parent_item = parent self.service = service ''':ivar self.service: service info as :ref:`fkie_master_discovery.ServiceInfo<http://docs.ros.org/kinetic/api/fkie_master_discovery/html/modules.html#fkie_master_discovery.master_info.ServiceInfo>`.''' self._with_namespace = rospy.names.SEP in service.name
def __init__(self, name, value, parent=None): ''' Initialize the item object. @param name: the name of the parameter @type name: C{str} @param value: the value of the parameter @type value: C{str} ''' QStandardItem.__init__(self, name) self._name = name '''@ivar: the name of parameter ''' self._value = value '''@ivar: the value of the parameter '''
def __init__(self, name, value, parent=None): """ Initialize the item object. @param name: the name of the parameter @type name: C{str} @param value: the value of the parameter @type value: C{str} """ QStandardItem.__init__(self, str(type(value)).replace("<type '", "").replace("'>", "")) self._name = name """@ivar: the name of parameter """ self._value = value """@ivar: the value of the parameter """
def __init__(self, name, topic=None, parent=None): ''' Initialize the topic item. :param str name: the topic name :param topic: the topic info :type topic: U{master_discovery_fkie.TopicInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.TopicInfo>} ''' QStandardItem.__init__(self, name) self._parent_item = parent self._publish_thread = None self.topic = TopicInfo(name) if topic is None else topic '''@ivar: topic as U{master_discovery_fkie.TopicInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.TopicInfo>}.''' self._with_namespace = rospy.names.SEP in name
def __init__(self, name, topic=None, parent=None): ''' Initialize the topic item. @param name: the topic name @type name: C{str} @param topic: the topic info @type topic: U{master_discovery_fkie.TopicInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.TopicInfo>} ''' QStandardItem.__init__(self, name) self.parent_item = parent self._publish_thread = None self.topic = TopicInfo(name) if topic is None else topic '''@ivar: topic as U{master_discovery_fkie.TopicInfo<http://docs.ros.org/kinetic/api/master_discovery_fkie/html/modules.html#master_discovery_fkie.master_info.TopicInfo>}.'''
def __init__(self, name, value, parent=None): ''' Initialize the item object. @param name: the name of the parameter @type name: C{str} @param value: the value of the parameter @type value: C{str} ''' QStandardItem.__init__(self, utf8(type(value)).replace("<type '", '').replace("'>", '')) self._name = name '''@ivar: the name of parameter ''' self._value = value '''@ivar: the value of the parameter '''
def update_connect_to_list(self, infer_name): self.connect_from_listmodel.clear() self.connect_to_listmodel.clear() for node in self.dotgraph.get_node_list(): pipeline_item = QStandardItem() pipeline_item.setText(node.get_name()) pipeline_item.setCheckable(True) pipeline_item.setCheckState(False) if node.get_name() == infer_name.encode('utf-8'): continue if node.get('nodetype') == 'input': self.connect_from_listmodel.appendRow(pipeline_item) # self.connect_from_listview.addItem(node.get_name()) elif node.get('nodetype') == 'output': self.connect_to_listmodel.appendRow(pipeline_item) # self.connect_to_listview.addItem(node.get_name()) elif node.get('nodetype') == 'infer': if infer_name in self.get_infer_desc(infer_name)['connect_from']: self.connect_from_listmodel.appendRow(pipeline_item) elif infer_name in self.get_infer_desc(infer_name)['connect_to']: self.connect_to_listmodel.appendRow(pipeline_item) self.connect_from_listview.setModel(self.connect_from_listmodel) self.connect_to_listview.setModel(self.connect_to_listmodel)
def __init__(self, name, value, parent=None): ''' Initialize the item object. @param name: the name of the parameter @type name: C{str} @param value: the value of the parameter @type value: C{str} ''' QStandardItem.__init__(self, utf8(value) if not isinstance(value, Binary) else utf8(value)) self._name = name '''@ivar: the name of parameter ''' self._value = value '''@ivar: the value of the parameter ''' if isinstance(value, (str, unicode)) and value.find('\n') > -1: self.setSizeHint(QSize(-1, 45))
def _append_items(self, item, deep): path = item.data(self.DATA_INC_FILE) if not path: path = item.data(self.DATA_FILE) if path in GRAPH_CACHE: for inc_lnr, inc_path in GRAPH_CACHE[path]: pkg, _ = package_name(os.path.dirname(inc_path)) itemstr = '%s [%s]' % (os.path.basename(inc_path), pkg) inc_item = QStandardItem('%d: %s' % (inc_lnr + 1, itemstr)) inc_item.setData(path, self.DATA_FILE) inc_item.setData(inc_lnr + 1, self.DATA_LINE) inc_item.setData(inc_path, self.DATA_INC_FILE) inc_item.setData(deep, self.DATA_LEVEL) self._append_items(inc_item, deep + 1) item.appendRow(inc_item)
def __init__(self, name, value, parent=None): """ Initialize the item object. @param name: the name of the parameter @type name: C{str} @param value: the value of the parameter @type value: C{str} """ QStandardItem.__init__(self, unicode(value) if not isinstance(value, Binary) else str(value)) self._name = name """@ivar: the name of parameter """ self._value = value """@ivar: the value of the parameter """ if isinstance(value, (str, unicode)) and value.find("\n") > -1: self.setSizeHint(QSize(-1, 45))
def _on_load_error(self, msg): self.setWindowTitle("Include Graph - %s" % os.path.basename(self._root_path)) if not self._created_tree: inc_item = QStandardItem('%s' % msg) self.graphTreeView.model().appendRow(inc_item) self.finished_signal.emit() self.info_signal.emit("build tree failed: %s" % msg, True)
def data(self, role): if role == self.NAME_ROLE: return self.topic.name elif role == self.NODENAMES_ROLE: return utf8(self.topic.publisherNodes) + utf8(self.topic.subscriberNodes) else: return QStandardItem.data(self, role)
def data(self, role): ''' The view asks us for all sorts of information about our data... @param role: the art of the data @type role: U{QtCore.Qt.DisplayRole<https://srinikom.github.io/pyside-docs/PySide/QtCore/Qt.html>} @see: U{http://www.pyside.org/docs/pyside-1.0.1/PySide/QtCore/Qt.html} ''' if role == Qt.DisplayRole: # return the displayed item name if self.id == LaunchItem.RECENT_FILE or self.id == LaunchItem.RECENT_PROFILE: return "%s [%s]" % (self.name, self.package_name) # .decode(sys.getfilesystemencoding()) else: return "%s" % self.name elif role == Qt.ToolTipRole: # return the tooltip of the item result = "%s" % self.path if self.id == LaunchItem.RECENT_FILE or self.id == LaunchItem.RECENT_PROFILE: result = "%s\nPress 'Delete' to remove the entry from the history list" % self.path return result # elif role == Qt.DecorationRole: # # return the showed icon # pathItem, path, pathId = self.items[index.row()] # if self.id > LaunchListModel.NOTHING and self.model().icons.has_key(self.id): # return self.model().icons[self.id] # return None elif role == Qt.EditRole: return "%s" % self.name else: # We don't care about anything else, so return default value return QStandardItem.data(self, role)
def data(self, role): if role == self.NAME_ROLE: return self.topic.name elif role == self.NODENAMES_ROLE: return str(self.topic.publisherNodes) + str(self.topic.subscriberNodes) else: return QStandardItem.data(self, role)
def data(self, role): ''' The view asks us for all sorts of information about our data... :param role: the art of the data :type role: :class:`QtCore.Qt.DisplayRole` <https://srinikom.github.io/pyside-docs/PySide/QtCore/Qt.html> :see: http://www.pyside.org/docs/pyside-1.0.1/PySide/QtCore/Qt.html ''' if role == Qt.DisplayRole: # return the displayed item name if self.id == PathItem.RECENT_FILE or self.id == PathItem.RECENT_PROFILE: return "%s [%s]" % (self.name, self.package_name ) # .decode(sys.getfilesystemencoding()) elif self.id == PathItem.REMOTE_DAEMON: return "//%s" % self.name else: return "%s" % self.name elif role == Qt.ToolTipRole: # return the tooltip of the item result = "%s" % self.path if self.id == PathItem.RECENT_FILE or self.id == PathItem.RECENT_PROFILE: result = "%s\nPress 'Delete' to remove the entry from the history list\nShift+'double click' goes to the file location" % self.path return result elif role == Qt.EditRole: return "%s" % self.name else: # We don't care about anything else, so return default value return QStandardItem.data(self, role)
def data(self, role): ''' The view asks us for all sorts of information about our data... @param role: the art of the data @type role: U{QtCore.Qt.DisplayRole<https://srinikom.github.io/pyside-docs/PySide/QtCore/Qt.html>} @see: U{http://www.pyside.org/docs/pyside-1.0.1/PySide/QtCore/Qt.html} ''' if role == Qt.DisplayRole: # return the displayed item name if self.id == LaunchItem.RECENT_FILE: return "%s [%s]" % (self.name, self.package_name) # .decode(sys.getfilesystemencoding()) else: return "%s" % self.name elif role == Qt.ToolTipRole: # return the tooltip of the item result = "%s" % self.path if self.id == LaunchItem.RECENT_FILE: result = "%s\nPress 'Delete' to remove the entry from the history list" % self.path return result # elif role == Qt.DecorationRole: # # return the showed icon # pathItem, path, pathId = self.items[index.row()] # if self.id > LaunchListModel.NOTHING and self.model().icons.has_key(self.id): # return self.model().icons[self.id] # return None elif role == Qt.EditRole: return "%s" % self.name else: # We don't care about anything else, so return default value return QStandardItem.data(self, role)
def setData(self, value, role=Qt.EditRole): if role == Qt.EditRole: self._value = value if hasattr(self._settings, self._attrname): setattr(self._settings, self._attrname, value) if self._need_restart: MessageBox.information(None, "restart Node Manager", "This parameter change is only valid after restart!") return QStandardItem.setData(self, value, role)
def data(self, role): if role == self.NAME_ROLE: return self.name elif role == self.VALUE_ROLE: return utf8(self.value) elif role == self.TYPE_ROLE: return utf8(type(self.value).replace('<type \'').replace('\'>')) else: return QStandardItem.data(self, role)
def data(self, role): if role == self.NAME_ROLE: return self.name elif role == self.VALUE_ROLE: return str(self.value) elif role == self.TYPE_ROLE: return str(type(self.value).replace("<type '").replace("'>")) else: return QStandardItem.data(self, role)
def data(self, role): if role == self.NAME_ROLE: return self.service.name elif role == self.TYPE_ROLE: return str(self.service.get_service_class(False)) elif role == self.NODENAMES_ROLE: return str(self.service.serviceProvider) else: return QStandardItem.data(self, role)
def data(self, role): if role == self.NAME_ROLE: return self.service.name elif role == self.TYPE_ROLE: return self.service_type_str elif role == self.NODENAMES_ROLE: return utf8(self.service.serviceProvider) else: return QStandardItem.data(self, role)
def _create_pipeline(self): pipeline_name, okPressed = QInputDialog.getText( self._widget, "Create a new pipeline", "new pipeline name:", QLineEdit.Normal, "") if okPressed != True or pipeline_name == '': #Empty name return pipeline_item = QStandardItem() pipeline_item.setText(pipeline_name) self._listmodel.appendRow(pipeline_item) new_dotgraph = dotparser.generate_dotcode_from_empty( self.dotcode_factory, pipeline_name) self._dotgraphs.update(new_dotgraph) self._current_pipeline_name = pipeline_name self._refresh_rosgraph()
def _load_pipeline(self): self._dotgraphs.clear() self._listmodel.clear() file_path, _ = QFileDialog.getOpenFileName( self._widget, "QFileDialog.getOpenFileName()", "", "*.yaml") self._dotgraphs = generate_dotcode_from_yaml_file( self.dotcode_factory, self.param_manager, str(file_path)) for pipeline_name, pipeline_dotgraph in self._dotgraphs.items(): pipeline_item = QStandardItem() pipeline_item.setText(pipeline_name) self._listmodel.appendRow(pipeline_item) self._current_pipeline_name = self._dotgraphs.iterkeys().next() self._refresh_rosgraph()
def __init__(self, name, parent=None, is_group=False): ''' Initialize the ServiceGroupItem object with given values. :param str name: the name of the group :param parent: the parent item. In most cases this is the HostItem. The variable is used to determine the different columns of the NodeItem. :type parent: :class:`QtGui.QStandardItem` <https://srinikom.github.io/pyside-docs/PySide/QtGui/QStandardItem.html> :param bool is_group: True if this is a capability group. In other case it is a namespace group. ''' dname = 'services@master/' if is_group: dname = '{%s}' % name elif name != rospy.names.SEP: dname = '%s/' % name QStandardItem.__init__(self, dname) self.parent_item = parent self._name = name self._is_group = is_group self.is_system_group = name == 'SYSTEM'
def create_item_list(self, name, parent, is_group): ''' Creates the list of the items for this group. This list is used for the visualization of group data as a table row. :param str name: the group name :return: the list for the representation as a row :rtype: C{[L{TopicGroupItem} or U{QStandardItem<https://srinikom.github.io/pyside-docs/PySide/QtGui/QStandardItem.html>}, ...]} ''' items = [] item = TopicGroupItem(name, parent, is_group) items.append(item) pubItem = QStandardItem() items.append(pubItem) subItem = QStandardItem() items.append(subItem) typeItem = QStandardItem() items.append(typeItem) return items
def _add_log(self, data): timestamp = QStandardItem( QDateTime.currentDateTime().toString('d.M.yyyy hh:mm:ss.zzz')) timestamp.setTextAlignment(Qt.AlignRight) timestamp.setEditable(False) message = QStandardItem(data) message.setEditable(False) row = [] row.append(timestamp) row.append(message) self._message_count = self._message_count + 1 self.model.insertRow(0, row) if self._message_count > self._message_limit: self.model.removeRow(self.model.rowCount() - 1) self._message_count = self._message_count - 1
def __init__(self, master, local=False, quality=None, parent=None): self.name = ''.join([master.name, ' (localhost)']) if local else master.name QStandardItem.__init__(self, self.name) self.parent_item = None self._master = master self.local = local self.__quality = quality self.descr = '' self.ICONS = {'green': QIcon(":/icons/stock_connect_green.png"), 'yellow': QIcon(":/icons/stock_connect_yellow.png"), 'red': QIcon(":/icons/stock_connect_red.png"), 'grey': QIcon(":/icons/stock_connect.png"), 'disconnected': QIcon(":/icons/stock_disconnect.png"), 'warning': QIcon(':/icons/crystal_clear_warning.png'), 'clock_warn': QIcon(':/icons/crystal_clear_xclock_fail.png')} self.master_ip = None self._master_errors = [] self._timediff = 0 self._threaded_get_ip() self.updateNameView(master, quality, self)
def _create_widgets_for_launchfile(self, config): self._config = config # Delete old nodes' GUIs. self._node_controllers = [] # These lines seem to remove indexWidgets previously set on treeview. # Per suggestion in API doc, we are not using reset(). Instead, # using 2 methods below without any operation in between, which # I suspect might be inproper. # http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#reset self._datamodel.beginResetModel() self._datamodel.endResetModel() # Need to store the num of nodes outside of the loop -- this will # be used for removing excessive previous node rows. order_xmlelement = 0 # Loop per xml element for order_xmlelement, node in enumerate(self._config.nodes): proxy = NodeProxy(self._run_id, self._config.master.uri, node) # TODO: consider using QIcon.fromTheme() status_label = StatusIndicator() qindex_nodewidget = self._datamodel.index(order_xmlelement, 0, QModelIndex()) node_widget = self._delegate.create_node_widget(qindex_nodewidget, proxy.config, status_label) #TODO: Ideally find a way so that we don't need this block. #BEGIN If these lines are missing, widget won't be shown either. std_item = QStandardItem( #node_widget.get_node_name() ) self._datamodel.setItem(order_xmlelement, 0, std_item) #END If these lines are missing, widget won't be shown either. self._treeview.setIndexWidget(qindex_nodewidget, node_widget) node_controller = NodeController(proxy, node_widget) self._node_controllers.append(node_controller) node_widget.connect_start_stop_button( \ node_controller.start_stop_slot) rospy.logdebug('loop #%d proxy.config.namespace=%s ' + 'proxy.config.name=%s', order_xmlelement, proxy.config.namespace, proxy.config.name) self._num_nodes_previous = order_xmlelement self._parent.set_node_controllers(self._node_controllers)
def __init__(self, master, local=False, quality=None, parent=None): self.name = ''.join([master.name, ' (localhost)']) if local else master.name QStandardItem.__init__(self, '') # self.name) self.parent_item = None self._master = master self.local = local self.__quality = quality self.descr = '' self.ICONS = {'green': nm.settings().icon('stock_connect_green.png'), 'yellow': nm.settings().icon('stock_connect_yellow.png'), 'red': nm.settings().icon('stock_connect_red.png'), 'grey': nm.settings().icon('stock_connect.png'), 'disconnected': nm.settings().icon('stock_disconnect.png'), 'warning': nm.settings().icon('crystal_clear_warning.png'), 'clock_warn': nm.settings().icon('crystal_clear_xclock_fail.png')} self.master_ip = None self._master_errors = [] self._diagnostics = [] self._timediff = 0 self._threaded_get_ip() self.updateNameView(master, quality, self)
def setData(self, value, role=Qt.EditRole): if role == Qt.EditRole: # rename the file or folder if self.name != value and self.id in [self.RECENT_FILE, self.LAUNCH_FILE, self.CFG_FILE, self.FOLDER]: new_path = os.path.join(os.path.dirname(self.path), value) if not os.path.exists(new_path): os.rename(self.path, new_path) self.name = value self.path = new_path else: WarningMessageBox(QMessageBox.Warning, "Path already exists", "`%s` already exists!" % value, "Complete path: %s" % new_path).exec_() return QStandardItem.setData(self, value, role)
def data(self, role): ''' The view asks us for all sorts of information about our data... @param role: the art of the data @type role: U{QtCore.Qt.DisplayRole<https://srinikom.github.io/pyside-docs/PySide/QtCore/Qt.html>} @see: U{http://www.pyside.org/docs/pyside-1.0.1/PySide/QtCore/Qt.html} ''' if role == Qt.DisplayRole: # return the displayed item name return self.name # elif role == Qt.DecorationRole: # pass else: # We don't care about anything else, so return None return QStandardItem.data(self, role)
def setData(self, value, role=Qt.EditRole): if role == Qt.EditRole: # rename the file or folder if self.name != value and self.id in [self.RECENT_FILE, self.LAUNCH_FILE, self.RECENT_PROFILE, self.PROFILE, self.CFG_FILE, self.FOLDER]: new_path = os.path.join(os.path.dirname(self.path), value) if not os.path.exists(new_path): os.rename(self.path, new_path) if self.name != value and self.id in [self.RECENT_FILE, self.RECENT_PROFILE]: # update in history nm.settings().launch_history_add(new_path, replace=self.path) self.name = value self.path = new_path else: MessageBox.warning(self, "Path already exists", "`%s` already exists!" % value, "Complete path: %s" % new_path) return QStandardItem.setData(self, value, role)
def data(self, role): ''' The view asks us for all sorts of information about our data... @param role: the art of the data @type role: L{QtCore.Qt.DisplayRole} @see: U{http://www.pyside.org/docs/pyside-1.0.1/PySide/QtCore/Qt.html} ''' if role == Qt.DisplayRole: # return the displayed item name return self.name elif role == Qt.ToolTipRole: # return the tooltip of the item return self.tooltip else: # We don't care about anything else, so return None return QStandardItem.data(self, role)
class TestRqtRosGraph(unittest.TestCase): """ :author: Isaac Saito """ def setUp(self): unittest.TestCase.setUp(self) self._model = QStandardItemModel() node1 = QStandardItem('node1') self._node1_1 = QStandardItem('node1_1') self._node1_1_1 = QStandardItem('node1_1_1') node1_1_2 = QStandardItem('node1_1_2') node1_2 = QStandardItem('node1_2') node1.appendRow(self._node1_1) self._node1_1.appendRow(self._node1_1_1) self._node1_1.appendRow(node1_1_2) node1.appendRow(node1_2) self._model.appendRow(node1) #node_list = [node1, node1_1, self._node1_1_1, node1_1_2, node1_2] #self._model.appendRow(node_list) self._grn_node1_1_1 = '/node1/node1_1/node1_1_1' self._len_lower_grn_node1_1 = 2 def tearDown(self): unittest.TestCase.tearDown(self) del self._model def test_get_upper_grn(self): self.assertEqual(RqtRosGraph.get_upper_grn(self._node1_1_1.index(), ''), self._grn_node1_1_1) def test_get_lower_grn_dfs(self): self.assertEqual(len(RqtRosGraph.get_lower_grn_dfs( self._node1_1.index(), '')), self._len_lower_grn_node1_1) def test_get_full_grn(self): self.assertEqual(RqtRosGraph.get_full_grn(self._node1_1_1.index()), self._grn_node1_1_1)
def setUp(self): unittest.TestCase.setUp(self) self._model = QStandardItemModel() node1 = QStandardItem('node1') self._node1_1 = QStandardItem('node1_1') self._node1_1_1 = QStandardItem('node1_1_1') node1_1_2 = QStandardItem('node1_1_2') node1_2 = QStandardItem('node1_2') node1.appendRow(self._node1_1) self._node1_1.appendRow(self._node1_1_1) self._node1_1.appendRow(node1_1_2) node1.appendRow(node1_2) self._model.appendRow(node1) #node_list = [node1, node1_1, self._node1_1_1, node1_1_2, node1_2] #self._model.appendRow(node_list) self._grn_node1_1_1 = '/node1/node1_1/node1_1_1' self._len_lower_grn_node1_1 = 2
def _on_ctrl_info(self, index): popup = self._popup_widget ctrl = self._controllers[index.row()] popup.ctrl_name.setText(ctrl.name) popup.ctrl_type.setText(ctrl.type) res_model = QStandardItemModel() model_root = QStandardItem('Claimed Resources') res_model.appendRow(model_root) for hw_res in ctrl.claimed_resources: hw_iface_item = QStandardItem(hw_res.hardware_interface) model_root.appendRow(hw_iface_item) for res in hw_res.resources: res_item = QStandardItem(res) hw_iface_item.appendRow(res_item) popup.resource_tree.setModel(res_model) popup.resource_tree.setItemDelegate(FontDelegate(popup.resource_tree)) popup.resource_tree.expandAll() popup.move(QCursor.pos()) popup.show()
def _get_data_items_for_path(self, slot_name, slot_type_name, slot_path, **kwargs): if slot_name.startswith('/'): return (CheckableItem(slot_name), ReadonlyItem(slot_type_name), QStandardItem(''), ReadonlyItem('')) expression_item = QStandardItem('') expression_item.setToolTip('enter valid Python expression here, using "i" as counter and functions from math, random and time modules') return (CheckableItem(slot_name), QStandardItem(slot_type_name), ReadonlyItem(''), expression_item)
def __init__(self, master): QStandardItem.__init__(self) self.name = master.name self.button = MasterSyncButtonHelper(master) self.parent_item = None
def __init__(self, name, tooltip=''): QStandardItem.__init__(self, name) self.name = name self.tooltip = tooltip
def __init__(self, name): QStandardItem.__init__(self, name) self.name = name
def setData(self, value, role=Qt.EditRole): if role == Qt.EditRole: self._value = value if hasattr(self._settings, self._attrname): setattr(self._settings, self._attrname, value) return QStandardItem.setData(self, value, role)
def _get_data_items_for_path(self, slot_name, slot_type, slot_path, **kwargs): expression_item = QStandardItem('') expression_item.setToolTip('enter valid Python expression here, using "i" as counter and functions from math, random and time modules') return (ReadonlyItem(slot_name), ReadonlyItem(QStandardItem(slot_type)), expression_item)
:type value: any std types :param settings: the object, which contains `attrname` as property and provide the parameter changes :type settings: object (Settings) :param attrname: the parameter name, which is available as property in `settings` object. :type attrname: str :param edit_type: the editor type will be detected automatically by default. For different editors you can set manually the `EDIT_TYPE_*` :type edit_type: int (`EDIT_TYPE_*`) :param value_default: the default value, is needed for reset functionality :param value_min: the maximum value (used by int or float) :param value_max: the minimum value (used by int or float) :param value_list: the list of values used for comboboxes ''' QStandardItem.__init__(self, '%s' % value) self._attrname = attrname self._value = value self._value_default = value_default self._value_min = value_min self._value_max = value_max self._settings = settings self._edit_type = edit_type self._value_list = value_list def type(self): return SettingsValueItem.ITEM_TYPE def attrname(self): return self._attrname
def _get_result_cb(self, status, res): rospy.loginfo("got result!") self._blocks_model.setRowCount(0) self._blocks_model.setRowCount(len(res.blocks)) for (i,block) in zip(range(len(res.blocks)),res.blocks): # Store in dict self.blocks[block.name] = block cb = QStandardItem(True) cb.setCheckable(True) cb.setCheckState(Qt.Checked if block.state.value == conman_msgs.msg.TaskState.RUNNING else Qt.Unchecked) cb.setTextAlignment(Qt.AlignHCenter) cb.setTristate(True) action = QStandardItem(True) action.setText("") state = QStandardItem(True) state.setText(state_map[block.state.value]) name = QStandardItem(True) name.setText(str(block.name)) self._blocks_model.setItem(i,0,cb) self._blocks_model.setItem(i,1,action) self._blocks_model.setItem(i,2,state) self._blocks_model.setItem(i,3,name) for (i,group) in zip(range(len(res.groups)),res.groups): self.groups[group.name] = group cb = QStandardItem(True) cb.setCheckable(True) cb.setCheckState(Qt.Checked) cb.setTextAlignment(Qt.AlignHCenter) cb.setEnabled(False) name = QStandardItem(True) name.setText(str(group.name)) self._groups_model.setItem(i,0,cb) self._groups_model.setItem(i,3,name) self._update_groups() self._update_blocks() self._widget.blocks_table.resizeColumnsToContents() self._widget.blocks_table.horizontalHeader().setStretchLastSection(True) self._widget.groups_table.resizeColumnsToContents() self._widget.groups_table.horizontalHeader().setStretchLastSection(True)