class RobotPart

Public Class Methods

new(parent) click to toggle source
Calls superclass method
# File examples/graphicsview/dragdroprobot/robot.rb, line 28
def initialize(parent)
    super(parent)
    @color = Qt::Color.new(Qt::lightGray)
    @pixmap = Qt::Pixmap.new
    @dragOver = false
    setAcceptDrops(true)
end

Public Instance Methods

dragEnterEvent(event) click to toggle source
# File examples/graphicsview/dragdroprobot/robot.rb, line 36
def dragEnterEvent(event)
    if event.mimeData.hasColor ||
        self.kind_of?(RobotHead) && event.mimeData.hasImage
        event.accepted = true
        @dragOver = true
        update()
    else
        event.accepted = false
    end
end
dragLeaveEvent(event) click to toggle source
# File examples/graphicsview/dragdroprobot/robot.rb, line 47
def dragLeaveEvent(event)
    @dragOver = false
    update()
end
dropEvent(event) click to toggle source
# File examples/graphicsview/dragdroprobot/robot.rb, line 52
def dropEvent(event)
    @dragOver = false
    if event.mimeData.hasColor
        @color = qVariantValue(Qt::Color, event.mimeData.colorData)
    elsif event.mimeData.hasImage
        @pixmap = qVariantValue(Qt::Pixmap, event.mimeData.imageData)
    end
    update()
end