Class: Roby::GUI::ObjectInfoView
- Defined in:
- lib/roby/gui/object_info_view.rb
Overview
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).
Instance Method Summary collapse
-
#activate ⇒ Object
Shows the widget and makes it visible (i.e. toplevel).
-
#display(obj, plan) ⇒ Object
Updates the view to display the information about
obj
. -
#initialize(parent = nil) ⇒ ObjectInfoView
constructor
A new instance of ObjectInfoView.
Constructor Details
#initialize(parent = nil) ⇒ ObjectInfoView
Returns a new instance of ObjectInfoView.
12 13 14 15 16 17 18 19 |
# File 'lib/roby/gui/object_info_view.rb', line 12 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 |
Instance Method Details
#activate ⇒ Object
Shows the widget and makes it visible (i.e. toplevel)
85 86 87 88 |
# File 'lib/roby/gui/object_info_view.rb', line 85 def activate show activateWindow end |
#display(obj, plan) ⇒ Object
Updates the view to display the information about obj
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/roby/gui/object_info_view.rb', line 26 def display(obj, plan) sections = [] if obj.kind_of?(Array) from, to, rel = obj section = [ rel.to_s, ["from: #{from}", "to: #{to}", "info: #{plan.task_relation_graph_for(rel).edge_info(from, to)}"] ] 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).to_s ["#{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 |