node_delegate.py
Go to the documentation of this file.
1 # Software License Agreement (BSD License)
2 #
3 # Copyright (c) 2012, Willow Garage, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 # * Neither the name of Willow Garage, Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 # POSSIBILITY OF SUCH DAMAGE.
32 #
33 # Author: Isaac Saito
34 
35 from python_qt_binding.QtCore import Qt
36 from python_qt_binding.QtWidgets import QStyledItemDelegate
37 import rospkg
38 
39 from rqt_launch.node_widget import NodeWidget
40 
41 
42 class NodeDelegate(QStyledItemDelegate):
43  __slots__ = ['status_label', 'respawn_toggle', 'spawn_count_label',
44  'launch_prefix_edit']
45 
46  def __init__(self, master_uri, rospack=None):
47  # respawn_toggle, spawn_count_label, launch_prefix_edit):
48  super(NodeDelegate, self).__init__()
49  self._master_uri = master_uri
50 
51  self._rospack = rospack
52  if rospack == None:
53  self._rospack = rospkg.RosPack()
54 
55  self._nodewidget_dict = {} # { QModelIndex : QWidget }
56 
57  def createEditor(self, parent, option, index):
58  '''Overridden'''
59 
60  nodewidget = self._nodewidget_dict[index]
61  # TODO: handle exception
62  return nodewidget
63 
64  def setEditorData(self, spinBox, index):
65  '''Overridden'''
66  value = index.model().data(index, Qt.EditRole)
67 
68  spinBox.setValue(value)
69 
70  def setModelData(self, spinBox, model, index):
71  '''Overridden'''
72  spinBox.interpretText()
73  value = spinBox.value()
74 
75  model.setData(index, value, Qt.EditRole)
76 
77  def updateEditorGeometry(self, editor, option, index):
78  '''Overridden'''
79  editor.setGeometry(option.rect)
80 
81  def create_node_widget(self, qindex, launch_config,
82  status_label):
83  '''
84  @type status_label: StatusIndicator
85  '''
86  nodewidget = NodeWidget(self._rospack,
87  self._master_uri, launch_config,
88  status_label)
89  self._nodewidget_dict[qindex] = nodewidget
90  return nodewidget
91 
92  def get_node_widget(self):
93  return self._node_widget
def __init__(self, master_uri, rospack=None)
def setModelData(self, spinBox, model, index)
def setEditorData(self, spinBox, index)
def createEditor(self, parent, option, index)
def create_node_widget(self, qindex, launch_config, status_label)
def updateEditorGeometry(self, editor, option, index)


rqt_launch
Author(s): Isaac Saito, Stuart Glaser
autogenerated on Wed Oct 14 2020 03:50:59