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 QAction, QIcon, QToolBar
00035
00036
00037 class TopicMessageView(MessageView):
00038 """
00039 A message view with a toolbar for navigating messages in a single topic.
00040 """
00041 def __init__(self, timeline, parent, topic):
00042 MessageView.__init__(self, timeline, topic)
00043
00044 self._parent = parent
00045 self._stamp = None
00046 self._name = parent.objectName()
00047
00048 self.toolbar = QToolBar()
00049 self._first_action = QAction(QIcon.fromTheme('go-first'), '', self.toolbar)
00050 self._first_action.triggered.connect(self.navigate_first)
00051 self.toolbar.addAction(self._first_action)
00052 self._prev_action = QAction(QIcon.fromTheme('go-previous'), '', self.toolbar)
00053 self._prev_action.triggered.connect(self.navigate_previous)
00054 self.toolbar.addAction(self._prev_action)
00055 self._next_action = QAction(QIcon.fromTheme('go-next'), '', self.toolbar)
00056 self._next_action.triggered.connect(self.navigate_next)
00057 self.toolbar.addAction(self._next_action)
00058 self._last_action = QAction(QIcon.fromTheme('go-last'), '', self.toolbar)
00059 self._last_action.triggered.connect(self.navigate_last)
00060 self.toolbar.addAction(self._last_action)
00061 parent.layout().addWidget(self.toolbar)
00062
00063 @property
00064 def parent(self):
00065 return self._parent
00066
00067 @property
00068 def stamp(self):
00069 return self._stamp
00070
00071
00072
00073 def message_viewed(self, bag, msg_details):
00074 _, _, self._stamp = msg_details[:3]
00075
00076
00077 def navigate_first(self):
00078 for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00079 self.timeline._timeline_frame.playhead = entry.time
00080 break
00081
00082 def navigate_previous(self):
00083 last_entry = None
00084 for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.start_stamp, self.timeline._timeline_frame.playhead):
00085 if entry.time < self.timeline._timeline_frame.playhead:
00086 last_entry = entry
00087
00088 if last_entry:
00089 self.timeline._timeline_frame.playhead = last_entry.time
00090
00091 def navigate_next(self):
00092 for entry in self.timeline.get_entries([self.topic], self.timeline._timeline_frame.playhead, self.timeline._timeline_frame.end_stamp):
00093 if entry.time > self.timeline._timeline_frame.playhead:
00094 self.timeline._timeline_frame.playhead = entry.time
00095 break
00096
00097 def navigate_last(self):
00098 last_entry = None
00099 for entry in self.timeline.get_entries([self.topic], *self.timeline._timeline_frame.play_region):
00100 last_entry = entry
00101
00102 if last_entry:
00103 self.timeline._timeline_frame.playhead = last_entry.time