class ListSum

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

columns[RW]
list_holder[RW]
renderers[RW]

Public Class Methods

new(list_holder) click to toggle source
Calls superclass method
# File lib/ListHolder/ListPanel/ListSum.rb, line 6
def initialize(list_holder)
        @list_holder=list_holder
        super()
        @columns=Hash.new
        @renderers=Hash.new
        @values=Hash.new
        set_no_show_all(true)
        set_border_width(0)
        set_resize_mode(Gtk::ResizeMode::PARENT)
        signal_connect('destroy'){|me|
                renderers.each_value{|r| r.destroy if r}
        }
end

Public Instance Methods

calculate() click to toggle source
# File lib/ListHolder/ListPanel/ListSum.rb, line 55
def calculate
        zero
        if list_holder.list.model
        list_holder.list.model.each{|model,path,iter|
                @columns.each_pair{|col_data,col| @values[col_data]+=iter[col.header["model_col"]].to_f}
        }
        end
        columns.each_key{|col_data| renderers[col_data].update(@values[col_data])}
end
inspect() click to toggle source
# File lib/ListHolder/ListPanel/ListSum.rb, line 65
def inspect
        "ListSum of #{list_holder.list}"
end
set_visible(visible) click to toggle source
Calls superclass method
# File lib/ListHolder/ListPanel/ListSum.rb, line 39
        def set_visible(visible)
                each{|child|
                        if visible
                                child.show
                        else
                                child.hide
                        end
#                       p child.inspect + child.visible?.to_s
                }
                super
        end
to_s() click to toggle source
# File lib/ListHolder/ListPanel/ListSum.rb, line 68
def to_s
        inspect
end
update(notifier) click to toggle source
# File lib/ListHolder/ListPanel/ListSum.rb, line 23
def update(notifier)
        @renderers.each_value{|renderer| renderer.destroy}
        @columns.clear
        @renderers.clear
        @values.clear
        list_holder.list.columns.each {|column| 
                renderers[column.data]=SumRendererText.new(column)
                pack_start(renderers[column.data])
                if column.summable?
                        @values[column.data]=0.0
                        @columns[column.data]=column
                end
        }
        return self
end
zero() click to toggle source
# File lib/ListHolder/ListPanel/ListSum.rb, line 51
def zero
        @values.each_key{|key| @values[key]=0.0}
end