Class: Qt::ComboBox

Inherits:
Object show all
Defined in:
lib/clevic/qt/qt_combo_box.rb,
lib/clevic/qt/qt_combo_box.rb

Overview

Adding these to Qt::Widget as the superclass doesn’t work for some reason.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delegateObject

Returns the value of attribute delegate.



52
53
54
# File 'lib/clevic/qt/qt_combo_box.rb', line 52

def delegate
  @delegate
end

Instance Method Details

#<<(item) ⇒ Object



9
10
11
12
# File 'lib/clevic/qt/qt_combo_box.rb', line 9

def <<( item )
  text, data = item_to_editor( item )
  add_item( text, data.to_variant )
end

#editor_to_item(data) ⇒ Object

wrapper for the delegate method so we don’t have to keep checking for nil values



40
41
42
43
44
45
46
# File 'lib/clevic/qt/qt_combo_box.rb', line 40

def editor_to_item( data )
  if data
    delegate.editor_to_item( data )
  else
    nil
  end
end

#include?(item) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/clevic/qt/qt_combo_box.rb', line 14

def include?( item )
  text, data = item_to_editor( item )
  find_data( data.to_variant ) != -1
end

#item_to_editor(item) ⇒ Object

wrapper for the delegate method so we don’t have to keep checking for nil values



30
31
32
33
34
35
36
# File 'lib/clevic/qt/qt_combo_box.rb', line 30

def item_to_editor( item )
  if item
    delegate.item_to_editor( item )
  else
    ['', nil ]
  end
end

#no_insert=(bool) ⇒ Object



5
6
7
# File 'lib/clevic/qt/qt_combo_box.rb', line 5

def no_insert=( bool )
  self.insert_policy = Qt::ComboBox::NoInsert if bool
end

#selected_itemObject



24
25
26
# File 'lib/clevic/qt/qt_combo_box.rb', line 24

def selected_item
  delegate.editor_to_item( item_data( self.current_index ).value )
end

#selected_item=(item) ⇒ Object



19
20
21
22
# File 'lib/clevic/qt/qt_combo_box.rb', line 19

def selected_item=( item )
  text, data = item_to_editor( item )
  self.current_index = find_data( data.to_variant )
end