module Ui::RelationsView::GraphicsViewBehaviour

Module used to extend the relation view GraphicsView object, to add double-click and context-menu events

Attributes

display[RW]

Public Instance Methods

contextMenuEvent(event) click to toggle source
Calls superclass method
# File lib/roby/gui/relations_view.rb, line 107
def contextMenuEvent(event)
    item = itemAt(event.pos)
    if item
        unless obj = display.object_of(item)
            return super(event)
        end
    end

    return unless obj.kind_of?(Roby::Task)

    menu = Qt::Menu.new
    hide_this     = menu.add_action("Hide")
    hide_children = menu.add_action("Hide children")
    show_children = menu.add_action("Show children")
    return unless action = menu.exec(event.globalPos)

    case action.text
    when "Hide"
        display.selected_objects.delete(obj)
    when "Hide children"
        obj.plan.compute_useful_tasks([obj]).each do |child|
            if child != obj
                display.selected_objects.delete(child)
            end
        end
    when "Show children"
        obj.plan.compute_useful_tasks([obj]).each do |child|
            if child != obj
                display.selected_objects << child
            end
        end
    end

    display.update
end
mouseDoubleClickEvent(event) click to toggle source
Calls superclass method
# File lib/roby/gui/relations_view.rb, line 90
def mouseDoubleClickEvent(event)
    item = itemAt(event.pos)
    if item
        obj = display.object_of(item) ||
            display.relation_of(item)

        if !obj
            return super(event)
        end
    end

    @object_info ||= Roby::GUI::ObjectInfoView.new
    if @object_info.display(obj)
        @object_info.activate
    end
end