publisher_tree_widget.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (c) 2011, Dorian Scholz, TU Darmstadt
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 the TU Darmstadt 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 HOLDER 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 from python_qt_binding.QtCore import Signal, Slot
34 from python_qt_binding.QtGui import QIcon
35 from python_qt_binding.QtWidgets import QAction
36 
37 from .publisher_tree_model import PublisherTreeModel
38 from rqt_py_common.message_tree_widget import MessageTreeWidget
39 from rqt_py_common.item_delegates import SpinBoxDelegate
40 
41 
43  remove_publisher = Signal(int)
44  publish_once = Signal(int)
45 
46  def __init__(self, parent=None):
47  super(PublisherTreeWidget, self).__init__(parent)
48  self.setModel(PublisherTreeModel(self))
49  self._action_remove_publisher = QAction(
50  QIcon.fromTheme('list-remove'), 'Remove Selected', self)
51  self._action_remove_publisher.triggered[bool].connect(self._handle_action_remove_publisher)
52  self._action_publish_once = QAction(
53  QIcon.fromTheme('media-playback-start'), 'Publish Selected Once', self)
54  self._action_publish_once.triggered[bool].connect(self._handle_action_publish_once)
55  self.setItemDelegateForColumn(self.model()._column_index['rate'],
56  SpinBoxDelegate(min_value=0, max_value=1000000, decimals=2))
57 
58  @Slot()
60  publisher_ids = self.model().get_publisher_ids(self.selectedIndexes())
61  for publisher_id in publisher_ids:
62  self.remove_publisher.emit(publisher_id)
63  self.model().remove_items_with_parents(self.selectedIndexes())
64 
65  def _context_menu_add_actions(self, menu, pos):
66  if self.selectionModel().hasSelection():
67  menu.addAction(self._action_remove_publisher)
68  menu.addAction(self._action_publish_once)
69  # let super class add actions
70  super(PublisherTreeWidget, self)._context_menu_add_actions(menu, pos)
71 
72  def _handle_action_remove_publisher(self, checked):
74 
75  def _handle_action_publish_once(self, checked):
76  for publisher_id in self.model().get_publisher_ids(self.selectedIndexes()):
77  self.publish_once.emit(publisher_id)


rqt_publisher
Author(s): Dorian Scholz
autogenerated on Thu Jun 6 2019 19:28:21