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
Returns a new instance of SubjectComboBoxDelegate.
204 205 206 207 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 204 def initialize(parent) super setup end |
Instance Method Details
#createEditor(parent, option, index) ⇒ Object
213 214 215 216 217 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 213 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
219 220 221 222 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 219 def setEditorData(editor, index) value = index.data editor.setCurrentIndex(editor.findData(value)) end |
#setModelData(editor, model, index) ⇒ Object
224 225 226 227 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 224 def setModelData(editor, model, index) value = editor.itemData(editor.currentIndex) model.setData(index, value, Qt::EditRole) end |
#setup ⇒ Object
209 210 211 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 209 def setup @subjects = Subject.all.sort_by(&:title) end |
#updateEditorGeometry(editor, option, index) ⇒ Object
229 230 231 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 229 def updateEditorGeometry(editor, option, index) editor.setGeometry(option.rect) end |