Method: StudyTableModel#setData

Defined in:
lib/tmis/interface/models/study_table_model.rb

#setData(index, variant, role = Qt::EditRole) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/tmis/interface/models/study_table_model.rb', line 146

def setData(index, variant, role = Qt::EditRole)
  if index.valid? and role == Qt::EditRole
    if (studies = @studies[index.column / 2][1][(index.row / 2) + 1]) && (studies[index.row % 2])
      study = studies[index.row % 2]
      EditStudyDialog.new().setupData(study).exec
      refresh
      emit studySaved(study.date.to_v) unless study.date == @date
    else
      study = Study.new
      study.groupable_type = 'Group'
      study.groupable_id = @groups[index.column / 2].id
      study.number = (1..6).to_a[index.row / 2]
      study.date = @date
      EditStudyDialog.new().setupData(study).exec
      unless study.new_record?
        refresh
        emit studySaved(study.date.to_v) unless study.date == @date
      end
    end
    emit dataChanged(index, index)
    true
  else
    false
  end
end