Class: Syskit::GUI::LoggingGroupsItem

Inherits:
LoggingConfigurationItemBase show all
Defined in:
lib/syskit/gui/logging_groups_item.rb

Overview

A QStandardItem to display a hash of Sysit::ShellInterface::LoggingGroup in a tree view

Instance Attribute Summary collapse

Attributes inherited from LoggingConfigurationItemBase

#current_model, #editing_model

Instance Method Summary collapse

Methods inherited from LoggingConfigurationItemBase

#accept_changes, #add_conf_item, #data, #deep_copy, #modified!, #reject_changes

Constructor Details

#initialize(logging_groups, label = '') ⇒ LoggingGroupsItem

Returns a new instance of LoggingGroupsItem



11
12
13
14
15
16
17
18
19
# File 'lib/syskit/gui/logging_groups_item.rb', line 11

def initialize(logging_groups, label = '')
    super(logging_groups)

    @items_name = Hash.new
    @items_value = Hash.new

    setText label
    update_groups(logging_groups)
end

Instance Attribute Details

#items_nameObject (readonly)

Returns the value of attribute items_name



10
11
12
# File 'lib/syskit/gui/logging_groups_item.rb', line 10

def items_name
  @items_name
end

#items_valueObject (readonly)

Returns the value of attribute items_value



10
11
12
# File 'lib/syskit/gui/logging_groups_item.rb', line 10

def items_value
  @items_value
end

Instance Method Details

#update_groups(groups) ⇒ Object

Updates the model according to a new hash



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/syskit/gui/logging_groups_item.rb', line 22

def update_groups(groups)
    @current_model.keys.each do |key|
        if !groups.key? key
            group_row = @items_name[key].index.row
            @items_name[key].clear
            @items_value[key].clear
            @items_name.delete key
            @items_value.delete key
            removeRow(group_row)
        end
    end

    @current_model = deep_copy(groups)
    @editing_model = deep_copy(groups)

    @current_model.keys.each do |key|
        if !@items_name.key? key
            @items_name[key], @items_value[key] = add_conf_item(key)
            @items_value[key].getter do
                @editing_model[key].enabled
            end
            @items_value[key].setter do |value|
                @editing_model[key].enabled = value
            end
        end
    end
end