Class: Qt::VBoxLayout
- Inherits:
-
Object
- Object
- Qt::VBoxLayout
- Includes:
- Freightrain::LayoutWidget
- Defined in:
- lib/extensions/qt/widgets/qt_layout.rb
Instance Method Summary collapse
- #bind(options) ⇒ Object
- #elements ⇒ Object
- #elements=(enumerable) ⇒ Object
- #get_new_item ⇒ Object
- #selected ⇒ Object
- #selected=(val) ⇒ Object
- #setup ⇒ Object
Methods included from Freightrain::LayoutWidget
Instance Method Details
#bind(options) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 58 def bind() if [:property].to_sym == :elements @viewmodel = ([:element].to_s + "_element_view_model").to_sym [:force] = true end super() end |
#elements ⇒ Object
36 37 38 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 36 def elements() return @elements end |
#elements=(enumerable) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 20 def elements=(enumerable) setup unless @ready @elements.each do |item| self.removeWidget(item.control) item.control.dispose end @elements.clear enumerable.each do |value| item = self.get_new_item item.value = value self.addWidget(item.control) item.control.show @elements << item end end |
#get_new_item ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 50 def get_new_item item = Freightrain[@viewmodel] item.signals.each do |key, signal| signal.connect(@signals[key]) if @signals[key] end return item end |
#selected ⇒ Object
40 41 42 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 40 def selected return @elements.select { |element| element.selected == true}.first end |
#selected=(val) ⇒ Object
44 45 46 47 48 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 44 def selected=(val) @elements.each do |element| element.set_selection(val == element.value) end end |
#setup ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/extensions/qt/widgets/qt_layout.rb', line 7 def setup @signals ||= {} selected_callback = @signals[:selected] @signals[:selected] = lambda do |value| elements.each do |item| item.set_selection(item.value == value) end selected_callback.call(value) if selected_callback end @elements ||= [] @ready = true end |