Class: RubyMVC::Views::GridTableView
- Inherits:
-
PeerView
- Object
- Toolkit::AbstractWidget
- View
- PeerView
- RubyMVC::Views::GridTableView
- Defined in:
- lib/ruby_mvc/views/grid_table_view.rb
Overview
This class is used to provide a default binding between a table model instance and a GridView.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from PeerView
Attributes inherited from View
Instance Method Summary collapse
-
#initialize(model, options = {}, &block) ⇒ GridTableView
constructor
A new instance of GridTableView.
Methods inherited from PeerView
create_widget, #method_missing, #peer, #signal_connect, #signal_disconnect, widget, widget_def
Methods included from Toolkit::SignalHandler::ClassMethods
#signal, #signals, #valid_signal!, #valid_signal?
Methods included from Toolkit::SignalHandler
#signal_connect, #signal_disconnect, #signal_emit
Constructor Details
#initialize(model, options = {}, &block) ⇒ GridTableView
Returns a new instance of GridTableView.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ruby_mvc/views/grid_table_view.rb', line 43 def initialize(model, = {}, &block) super(, &block) # initialize the default state of the peer widget .model = model .editable = [:editable] # Create the actions for the model action(:new, :label => "New row", :icon => :stock_new) do model.insert_rows(-1, model.create_rows) idx = model.size - 1 signal_emit("row-edit", self, model, idx, model[idx]) end action(:delete, :label => "Delete", :enable => :select_multi, :icon => :stock_delete ) do puts "rows: #{widget.selected_rows.inspect}" .selected_rows.reverse_each do |i| model.remove_row(i) end end action(:edit, :label => "Edit...", :enable => :select_single, :icon => :stock_edit ) do idx = .selected_rows.first row = model[idx] signal_emit("row-edit", self, model, idx, row) end .signal_connect("row-selection-changed") do |s, m, rows| puts "selection changed: #{rows.inspect}" @actions.each do |a| a.selection(s, m, rows) end end .signal_connect("row-activated") do |s, m, r, k| row = model[r] signal_emit("row-edit", self, model, r, row) end puts "self.class.signals: #{self.class.signals.keys.inspect}" puts "widget.class.signals: #{widget.class.signals.keys.inspect}" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RubyMVC::Views::PeerView