Class: LecturerComboBoxDelegate

Inherits:
Qt::ItemDelegate
  • Object
show all
Defined in:
lib/tmis/interface/models/speciality_subject_table_model.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ LecturerComboBoxDelegate

Returns a new instance of LecturerComboBoxDelegate.



173
174
175
176
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 173

def initialize(parent)
  super
  setup
end

Instance Method Details

#createEditor(parent, option, index) ⇒ Object



182
183
184
185
186
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 182

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



188
189
190
191
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 188

def setEditorData(editor, index)
  value = index.data
  editor.setCurrentIndex(editor.findData(value))
end

#setModelData(editor, model, index) ⇒ Object



193
194
195
196
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 193

def setModelData(editor, model, index)
  value = editor.itemData(editor.currentIndex)
  model.setData(index, value, Qt::EditRole)
end

#setupObject



178
179
180
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 178

def setup
  @lecturers = Lecturer.all.sort_by(&:surname)
end

#updateEditorGeometry(editor, option, index) ⇒ Object



198
199
200
# File 'lib/tmis/interface/models/speciality_subject_table_model.rb', line 198

def updateEditorGeometry(editor, option, index)
  editor.setGeometry(option.rect)
end