Class: Shirka::Controller
- Inherits:
-
Object
- Object
- Shirka::Controller
- Includes:
- Eventalk
- Defined in:
- lib/shirka/controller.rb
Direct Known Subclasses
DetailPanelObjectController, EditorController, MainController, Qt::ListController, Qt::ListItemController, Qt::MultipanelController, Qt::TreeController, Qt::TreeItemController
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#parent ⇒ Object
Returns the value of attribute parent.
- #view ⇒ Object
Instance Method Summary collapse
- #add_component(component, slot = nil) ⇒ Object
- #add_item(text = '', controller_class = nil) ⇒ Object
- #init(data) ⇒ Object
-
#initialize(app, parent = nil, data = nil) ⇒ Controller
constructor
A new instance of Controller.
- #item_controller_class ⇒ Object
- #on_component_added(data = nil) ⇒ Object
- #on_component_adding(data = nil) ⇒ Object
- #view_class ⇒ Object
Methods included from Eventalk
#add_watcher, #fire, #forward, #watch, #watchers
Constructor Details
#initialize(app, parent = nil, data = nil) ⇒ Controller
Returns a new instance of Controller.
11 12 13 14 15 16 17 18 |
# File 'lib/shirka/controller.rb', line 11 def initialize(app, parent=nil, data=nil) @app = app @parent = parent @components = Components.new @data = data watch @app init data end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/shirka/controller.rb', line 7 def app @app end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
6 7 8 |
# File 'lib/shirka/controller.rb', line 6 def components @components end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/shirka/controller.rb', line 9 def data @data end |
#parent ⇒ Object
Returns the value of attribute parent.
8 9 10 |
# File 'lib/shirka/controller.rb', line 8 def parent @parent end |
#view ⇒ Object
28 29 30 |
# File 'lib/shirka/controller.rb', line 28 def view @view ||= view_class.new self end |
Instance Method Details
#add_component(component, slot = nil) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/shirka/controller.rb', line 43 def add_component(component, slot=nil) component.parent = self @components.add slot, component component.on_component_adding view.on_view_adding component.view, slot end |
#add_item(text = '', controller_class = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/shirka/controller.rb', line 37 def add_item(text='', controller_class=nil) controller_class ||= item_controller_class comp = controller_class.new app, self, text add_component comp end |
#init(data) ⇒ Object
20 21 |
# File 'lib/shirka/controller.rb', line 20 def init(data) end |
#item_controller_class ⇒ Object
32 33 34 35 |
# File 'lib/shirka/controller.rb', line 32 def item_controller_class name = self.class.to_s.sub(/Controller$/, 'ItemController') Object.const_get name rescue ::Shirka::Controller end |
#on_component_added(data = nil) ⇒ Object
53 54 |
# File 'lib/shirka/controller.rb', line 53 def on_component_added(data=nil) end |
#on_component_adding(data = nil) ⇒ Object
50 51 |
# File 'lib/shirka/controller.rb', line 50 def on_component_adding(data=nil) end |