Class: Syskit::GUI::RubyItem
- Inherits:
-
Vizkit::VizkitAccessorItem
- Object
- Vizkit::VizkitAccessorItem
- Syskit::GUI::RubyItem
- Defined in:
- lib/syskit/gui/ruby_item.rb
Overview
A QStandardItem to display and edit primitive ruby types in a tree view
Instance Method Summary collapse
-
#getter(&block) ⇒ Object
Defines a block to be called to fetch data from the model.
-
#initialize ⇒ RubyItem
constructor
A new instance of RubyItem.
- #setData(data, role = Qt::UserRole+1) ⇒ Object
-
#setter(&block) ⇒ Object
Defines a block to be called to update the model when the item is edited.
Constructor Details
#initialize ⇒ RubyItem
Returns a new instance of RubyItem
9 10 11 12 |
# File 'lib/syskit/gui/ruby_item.rb', line 9 def initialize super(nil, :nil?) setEditable false end |
Instance Method Details
#getter(&block) ⇒ Object
Defines a block to be called to fetch data from the model
30 31 32 |
# File 'lib/syskit/gui/ruby_item.rb', line 30 def getter(&block) @getter = block end |
#setData(data, role = Qt::UserRole+1) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/syskit/gui/ruby_item.rb', line 14 def setData(data,role = Qt::UserRole+1) return super if role != Qt::EditRole || data.isNull val = from_variant data, @getter.call return false if val.nil? return false unless val != @getter.call @setter.call val modified! end |
#setter(&block) ⇒ Object
Defines a block to be called to update the model when the item is edited
24 25 26 27 |
# File 'lib/syskit/gui/ruby_item.rb', line 24 def setter(&block) @setter = block setEditable true end |