Method: TreeItem#initialize

Defined in:
lib/Qt/active_item_model.rb

#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 'lib/Qt/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