Class: Syskit::GUI::LoggingConfigurationItemBase
- Inherits:
-
Vizkit::VizkitItem
- Object
- Vizkit::VizkitItem
- Syskit::GUI::LoggingConfigurationItemBase
- 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
Instance Attribute Summary collapse
-
#current_model ⇒ Object
readonly
Returns the value of attribute current_model.
-
#editing_model ⇒ Object
readonly
Returns the value of attribute editing_model.
Instance Method Summary collapse
- #accept_changes ⇒ Object
-
#add_conf_item(label, accessor = nil) ⇒ Object
Adds a ruby primitive type to the tree view.
- #data(role = Qt::UserRole+1) ⇒ Object
-
#deep_copy(model) ⇒ Object
Creates a marshallable deep copy of the object.
-
#initialize(model) ⇒ LoggingConfigurationItemBase
constructor
A new instance of LoggingConfigurationItemBase.
-
#modified!(value = true, items = [], update_parent = false) ⇒ Object
Updates view's sibling modified? state possibly rejecting changes made to the model.
- #reject_changes ⇒ Object
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_model ⇒ Object (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_model ⇒ Object (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_changes ⇒ Object
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_changes ⇒ Object
64 65 66 |
# File 'lib/syskit/gui/logging_configuration_item_base.rb', line 64 def reject_changes @editing_model = deep_copy(@current_model) end |