Class: SpecialityComboBoxDelegate
- Defined in:
- lib/tmis/interface/models/group_table_model.rb,
lib/tmis/interface/models/speciality_subject_table_model.rb
Instance Method Summary collapse
- #createEditor(parent, option, index) ⇒ Object
-
#initialize(parent) ⇒ SpecialityComboBoxDelegate
constructor
A new instance of SpecialityComboBoxDelegate.
- #setEditorData(editor, index) ⇒ Object
- #setModelData(editor, model, index) ⇒ Object
- #setup ⇒ Object
- #updateEditorGeometry(editor, option, index) ⇒ Object
Constructor Details
#initialize(parent) ⇒ SpecialityComboBoxDelegate
Returns a new instance of SpecialityComboBoxDelegate.
131 132 133 134 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 131 def initialize(parent) super setup end |
Instance Method Details
#createEditor(parent, option, index) ⇒ Object
140 141 142 143 144 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 140 def createEditor(parent, option, index) editor = Qt::ComboBox.new(parent) @specialities.each{ |x| editor.addItem(x.title.to_s, x.id.to_v) } editor end |
#setEditorData(editor, index) ⇒ Object
146 147 148 149 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 146 def setEditorData(editor, index) value = index.data editor.setCurrentIndex(editor.findData(value)) end |
#setModelData(editor, model, index) ⇒ Object
151 152 153 154 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 151 def setModelData(editor, model, index) value = editor.itemData(editor.currentIndex) model.setData(index, value, Qt::EditRole) end |
#setup ⇒ Object
136 137 138 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 136 def setup @specialities = Speciality.all.sort_by(&:title) end |
#updateEditorGeometry(editor, option, index) ⇒ Object
156 157 158 |
# File 'lib/tmis/interface/models/group_table_model.rb', line 156 def updateEditorGeometry(editor, option, index) editor.setGeometry(option.rect) end |