Class: TreeItem
- Defined in:
- ext/ruby/qtruby/rails_support/active_item_model.rb
Instance Attribute Summary collapse
-
#childItems ⇒ Object
readonly
Returns the value of attribute childItems.
-
#itemData ⇒ Object
readonly
Returns the value of attribute itemData.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #appendChild(item) ⇒ Object
- #child(row) ⇒ Object
- #childCount ⇒ Object
- #columnCount ⇒ Object
- #data(column) ⇒ Object
-
#initialize(item, keys, parent = nil, prefix = "") ⇒ TreeItem
constructor
A new instance of TreeItem.
- #parent ⇒ Object
- #row ⇒ Object
Constructor Details
#initialize(item, keys, parent = nil, prefix = "") ⇒ TreeItem
Returns a new instance of TreeItem.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 30 def initialize(item, keys, parent = nil, prefix="") @keys = keys @parentItem = parent @childItems = [] @resource = item if @resource.respond_to? :attributes @resource.attributes.inject(@itemData = {}) do |data, a| if a[1].respond_to? :attributes TreeItem.new(a[1], @keys, self, prefix + a[0] + ".") else data[prefix + a[0]] = a[1] end data end else @itemData = item end if @parentItem @parentItem.appendChild(self) end end |
Instance Attribute Details
#childItems ⇒ Object (readonly)
Returns the value of attribute childItems.
28 29 30 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 28 def childItems @childItems end |
#itemData ⇒ Object (readonly)
Returns the value of attribute itemData.
28 29 30 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 28 def itemData @itemData end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
28 29 30 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 28 def resource @resource end |
Instance Method Details
#appendChild(item) ⇒ Object
53 54 55 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 53 def appendChild(item) @childItems.push(item) end |
#child(row) ⇒ Object
57 58 59 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 57 def child(row) return @childItems[row] end |
#childCount ⇒ Object
61 62 63 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 61 def childCount return @childItems.length end |
#columnCount ⇒ Object
65 66 67 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 65 def columnCount return @itemData.length end |
#data(column) ⇒ Object
69 70 71 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 69 def data(column) return Qt::Variant.new(@itemData[@keys[column]]) end |
#parent ⇒ Object
73 74 75 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 73 def parent return @parentItem end |
#row ⇒ Object
77 78 79 80 81 82 83 |
# File 'ext/ruby/qtruby/rails_support/active_item_model.rb', line 77 def row if !@parentItem.nil? return @parentItem.childItems.index(self) end return 0 end |