Class: SemesterComboBoxDelegate
- Defined in:
- lib/tmis/interface/models/speciality_subject_table_model.rb
Instance Method Summary collapse
- #createEditor(parent, option, index) ⇒ Object
-
#initialize(parent) ⇒ SemesterComboBoxDelegate
constructor
A new instance of SemesterComboBoxDelegate.
- #setEditorData(editor, index) ⇒ Object
- #setModelData(editor, model, index) ⇒ Object
- #setup ⇒ Object
- #updateEditorGeometry(editor, option, index) ⇒ Object
Constructor Details
#initialize(parent) ⇒ SemesterComboBoxDelegate
Returns a new instance of SemesterComboBoxDelegate.
229 230 231 232 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 229 def initialize(parent) super setup end |
Instance Method Details
#createEditor(parent, option, index) ⇒ Object
238 239 240 241 242 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 238 def createEditor(parent, option, index) editor = Qt::ComboBox.new(parent) @semesters.each{ |x| editor.addItem(x.title.to_s, x.id.to_v) } editor end |
#setEditorData(editor, index) ⇒ Object
244 245 246 247 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 244 def setEditorData(editor, index) value = index.data editor.setCurrentIndex(editor.findData(value)) end |
#setModelData(editor, model, index) ⇒ Object
249 250 251 252 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 249 def setModelData(editor, model, index) value = editor.itemData(editor.currentIndex) model.setData(index, value, Qt::EditRole) end |
#setup ⇒ Object
234 235 236 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 234 def setup @semesters = Semester.all.sort_by(&:title) end |
#updateEditorGeometry(editor, option, index) ⇒ Object
254 255 256 |
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 254 def updateEditorGeometry(editor, option, index) editor.setGeometry(option.rect) end |