Class: Shirka::Qt::TreeItemController

Inherits:
Controller
  • Object
show all
Defined in:
lib/shirka/qt/tree_item/controller.rb

Instance Attribute Summary

Attributes inherited from Controller

#app, #components, #data, #parent

Instance Method Summary collapse

Methods inherited from Controller

#add_component, #on_component_added

Methods included from Eventalk

#add_watcher, #fire, #forward, #watch, #watchers

Constructor Details

#initialize(app, parent = nil, data = nil) ⇒ TreeItemController

Returns a new instance of TreeItemController.



5
6
7
8
9
10
11
12
13
# File 'lib/shirka/qt/tree_item/controller.rb', line 5

def initialize(app, parent=nil, data=nil)    
  @app = app
  @parent = parent
  @components = Components.new
  @root = data[:root]
  @data = data[:text]
  watch @app
  init @data
end

Instance Method Details

#add_item(text = '', controller_class = nil) ⇒ Object



28
29
30
31
32
# File 'lib/shirka/qt/tree_item/controller.rb', line 28

def add_item(text='', controller_class=nil)
  controller_class ||= item_controller_class
  comp = controller_class.new app, self, {text: text, root: @root}
  add_component comp
end

#idObject



42
43
44
# File 'lib/shirka/qt/tree_item/controller.rb', line 42

def id 
  view.id
end

#init(data) ⇒ Object



15
16
17
# File 'lib/shirka/qt/tree_item/controller.rb', line 15

def init(data)
  data.each { |i| add_item i } if data.respond_to? :each
end

#item_controller_classObject



34
35
36
# File 'lib/shirka/qt/tree_item/controller.rb', line 34

def item_controller_class
  self.class rescue ::Shirka::Qt::TreeItemController
end

#on_component_adding(data = nil) ⇒ Object



38
39
40
# File 'lib/shirka/qt/tree_item/controller.rb', line 38

def on_component_adding(data=nil)
  @root.on_component_added self, id
end

#on_double_clickedObject



46
47
# File 'lib/shirka/qt/tree_item/controller.rb', line 46

def on_double_clicked
end

#viewObject



24
25
26
# File 'lib/shirka/qt/tree_item/controller.rb', line 24

def view
  @view ||= view_class.new self, data
end

#view_classObject



19
20
21
22
# File 'lib/shirka/qt/tree_item/controller.rb', line 19

def view_class
  name = self.class.to_s.sub(/Controller$/, 'View')
  Object.const_get name rescue ::Shirka::Qt::TreeItemView
end