Class: Syskit::GUI::LoggingConfigurationItemBase

Inherits:
Vizkit::VizkitItem
  • Object
show all
Defined in:
lib/syskit/gui/logging_configuration_item_base.rb

Overview

Base class for most items in the LoggingConfiguration widget with common functionality

Direct Known Subclasses

LoggingConfigurationItem, LoggingGroupsItem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ LoggingConfigurationItemBase

Returns a new instance of LoggingConfigurationItemBase



12
13
14
15
16
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 12

def initialize(model)
    super()
    @current_model = deep_copy(model)
    @editing_model = deep_copy(model)
end

Instance Attribute Details

#current_modelObject (readonly)

Returns the value of attribute current_model



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

def current_model
  @current_model
end

#editing_modelObject (readonly)

Returns the value of attribute editing_model



11
12
13
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 11

def editing_model
  @editing_model
end

Instance Method Details

#accept_changesObject



68
69
70
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 68

def accept_changes
    @current_model = deep_copy(@editing_model)
end

#add_conf_item(label, accessor = nil) ⇒ Object

Adds a ruby primitive type to the tree view



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 24

def add_conf_item(label, accessor = nil)
    item1 = Vizkit::VizkitItem.new(label)
    item2 = RubyItem.new

    if !accessor.nil?
        item2.getter do
            @editing_model.method(accessor).call
        end

        item2.setter do |value|
            @editing_model.method("#{accessor}=".to_sym).call value
        end
    end

    appendRow([item1, item2])
    return item1, item2
end

#data(role = Qt::UserRole+1) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 42

def data(role = Qt::UserRole+1)
    if role == Qt::EditRole 
        Qt::Variant.from_ruby self
    else
        super
    end
end

#deep_copy(model) ⇒ Object

Creates a marshallable deep copy of the object



19
20
21
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 19

def deep_copy(model)
    Marshal.load(Marshal.dump(model))
end

#modified!(value = true, items = [], update_parent = false) ⇒ Object

Updates view's sibling modified? state possibly rejecting changes made to the model



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 52

def modified!(value = true, items = [],update_parent = false)
    super
    reject_changes unless value
    if column == 0
        i = index.sibling(row,1)
        if i.isValid
            item = i.model.itemFromIndex i
            item.modified!(value,items)
        end
    end
end

#reject_changesObject



64
65
66
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 64

def reject_changes
    @editing_model = deep_copy(@current_model)
end