Class: LecturerComboBoxDelegate
- Defined in:
- lib/tmis/interface/models/speciality_subject_table_model.rb
Instance Method Summary collapse
- #createEditor(parent, option, index) ⇒ Object
-
#initialize(parent) ⇒ LecturerComboBoxDelegate
constructor
A new instance of LecturerComboBoxDelegate.
- #setEditorData(editor, index) ⇒ Object
- #setModelData(editor, model, index) ⇒ Object
- #setup ⇒ Object
- #updateEditorGeometry(editor, option, index) ⇒ Object
Constructor Details
#initialize(parent) ⇒ LecturerComboBoxDelegate
Returns a new instance of LecturerComboBoxDelegate.
167 168 169 170 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 167 def initialize(parent) super setup end |
Instance Method Details
#createEditor(parent, option, index) ⇒ Object
176 177 178 179 180 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 176 def createEditor(parent, option, index) editor = Qt::ComboBox.new(parent) @lecturers.each{ |x| editor.addItem(x.surname.to_s, x.id.to_v) } editor end |
#setEditorData(editor, index) ⇒ Object
182 183 184 185 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 182 def setEditorData(editor, index) value = index.data editor.setCurrentIndex(editor.findData(value)) end |
#setModelData(editor, model, index) ⇒ Object
187 188 189 190 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 187 def setModelData(editor, model, index) value = editor.itemData(editor.currentIndex) model.setData(index, value, Qt::EditRole) end |
#setup ⇒ Object
172 173 174 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 172 def setup @lecturers = Lecturer.all.sort_by(&:surname) end |
#updateEditorGeometry(editor, option, index) ⇒ Object
192 193 194 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 192 def updateEditorGeometry(editor, option, index) editor.setGeometry(option.rect) end |