Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 from .message_view import MessageView
00033
00034 from python_qt_binding.QtGui import QIcon
00035 from python_qt_binding.QtWidgets import QAction, QToolBar
00036
00037
00038 class TopicMessageView(MessageView):
00039 """
00040 A message view with a toolbar for navigating messages in a single topic.
00041 """
00042 def __init__(self, timeline, parent, topic):
00043 MessageView.__init__(self, timeline, topic)
00044
00045 self._parent = parent
00046 self._stamp = None
00047 self._name = parent.objectName()
00048
00049 self.toolbar = QToolBar()
00050 self._first_action = QAction(QIcon.fromTheme('go-first'), '', self.toolbar)
00051 self._first_action.triggered.connect(self.navigate_first)
00052 self.toolbar.addAction(self._first_action)
00053 self._prev_action = QAction(QIcon.fromTheme('go-previous'), '', self.toolbar)
00054 self._prev_action.triggered.connect(self.navigate_previous)
00055 self.toolbar.addAction(self._prev_action)
00056 self._next_action = QAction(QIcon.fromTheme('go-next'), '', self.toolbar)
00057 self._next_action.triggered.connect(self.navigate_next)
00058 self.toolbar.addAction(self._next_action)
00059 self._last_action = QAction(QIcon.fromTheme('go-last'), '', self.toolbar)
00060 self._last_action.triggered.connect(self.navigate_last)
00061 self.toolbar.addAction(self._last_action)
00062 parent.layout().addWidget(self.toolbar)
00063
00064 @property
00065 def parent(self):
00066 return self._parent
00067
00068 @property
00069 def stamp(self):
00070 return self._stamp
00071
00072
00073
00074 def message_viewed(self, bag, msg_details):
00075 _, _, self._stamp = msg_details[:3]
00076
00077
00078 def navigate_first(self):
00079 for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00080 self.timeline._timeline_frame.playhead = entry.time
00081 break
00082
00083 def navigate_previous(self):
00084 last_entry = None
00085 for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.start_stamp, self.timeline._timeline_frame.playhead):
00086 if entry.time < self.timeline._timeline_frame.playhead:
00087 last_entry = entry
00088
00089 if last_entry:
00090 self.timeline._timeline_frame.playhead = last_entry.time
00091
00092 def navigate_next(self):
00093 for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.playhead, self.timeline._timeline_frame.end_stamp):
00094 if entry.time > self.timeline._timeline_frame.playhead:
00095 self.timeline._timeline_frame.playhead = entry.time
00096 break
00097
00098 def navigate_last(self):
00099 last_entry = None
00100 for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00101 last_entry = entry
00102
00103 if last_entry:
00104 self.timeline._timeline_frame.playhead = last_entry.time