class Roby::GUI::ObjectInfoView
Widget that can be used to display the information about a plan object (either relation or task)
The object should be provided to display
to update the view. activate
can then be used to show the widget and make it toplevel (force its visibility).
Public Class Methods
new(parent = nil)
click to toggle source
Calls superclass method
# File lib/roby/gui/object_info_view.rb, line 10 def initialize(parent = nil) super resize(400, 400) connect(SIGNAL('itemDoubleClicked(QListWidgetItem*)')) do |item| emit selectedTime(item.data(Qt::UserRole).to_date_time) end end
Public Instance Methods
activate()
click to toggle source
Shows the widget and makes it visible (i.e. toplevel)
# File lib/roby/gui/object_info_view.rb, line 82 def activate show activateWindow end
display(obj)
click to toggle source
Updates the view to display the information about obj
# File lib/roby/gui/object_info_view.rb, line 24 def display(obj) sections = [] if obj.kind_of?(Array) from, to, rel = obj section = [ "#{rel}", [ "from: #{from}", "to: #{to}", "info: #{from[to, rel]}"] ] sections << section elsif obj.kind_of?(Task) sections << ["Model", [obj.model.name]] # Add general task information (owner, arguments, ...) text = obj.arguments.map do |key, value| "#{key}: #{value}" end sections << ["Arguments", text] # Add the history if obj.failed_to_start? text = [] text << ["Failed to start at #{Roby.format_time(obj.failed_to_start_time)}", obj.failed_to_start_time] text.concat(Roby.format_exception(obj)) else text = obj.history.map do |event| time_as_text = "#{Roby.format_time(event.time)}" ["#{time_as_text}: #{event.symbol}", event.time] end end sections << ["History", text] sections << ["Model Ancestry", obj.model.ancestors.map(&:name)] else return false end self.windowTitle = "Details for #{obj}" clear sections.each do |header, lines| if header item = Qt::ListWidgetItem.new(self) item.text = header item.background = Qt::Brush.new(Qt::Color.new("#45C1FF")) font = item.font font.weight = Qt::Font::Bold item.font = font end lines.each do |txt, time| item = Qt::ListWidgetItem.new(" #{txt}") if time item.setData(Qt::UserRole, Qt::Variant.new(Qt::DateTime.new(time))) end addItem(item) end end end