Class: SubjectComboBoxDelegate
- Defined in:
- lib/tmis/interface/models/speciality_subject_table_model.rb
Instance Method Summary collapse
- #createEditor(parent, option, index) ⇒ Object
-
#initialize(parent) ⇒ SubjectComboBoxDelegate
constructor
A new instance of SubjectComboBoxDelegate.
- #setEditorData(editor, index) ⇒ Object
- #setModelData(editor, model, index) ⇒ Object
- #setup ⇒ Object
- #updateEditorGeometry(editor, option, index) ⇒ Object
Constructor Details
#initialize(parent) ⇒ SubjectComboBoxDelegate
198 199 200 201 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 198 def initialize(parent) super setup end |
Instance Method Details
#createEditor(parent, option, index) ⇒ Object
207 208 209 210 211 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 207 def createEditor(parent, option, index) editor = Qt::ComboBox.new(parent) @subjects.each{ |x| editor.addItem(x.title.to_s, x.id.to_v) } editor end |
#setEditorData(editor, index) ⇒ Object
213 214 215 216 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 213 def setEditorData(editor, index) value = index.data editor.setCurrentIndex(editor.findData(value)) end |
#setModelData(editor, model, index) ⇒ Object
218 219 220 221 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 218 def setModelData(editor, model, index) value = editor.itemData(editor.currentIndex) model.setData(index, value, Qt::EditRole) end |
#setup ⇒ Object
203 204 205 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 203 def setup @subjects = Subject.all.sort_by(&:title) end |
#updateEditorGeometry(editor, option, index) ⇒ Object
223 224 225 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 223 def updateEditorGeometry(editor, option, index) editor.setGeometry(option.rect) end |