Class: FindDialog
- Defined in:
- lib/tmis/interface/forms/find.rb
Overview
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instance Method Summary collapse
- #cancel ⇒ Object
-
#initialize(entity, parent = nil) ⇒ FindDialog
constructor
A new instance of FindDialog.
- #ok ⇒ Object
- #show_message(text) ⇒ Object
Constructor Details
#initialize(entity, parent = nil) ⇒ FindDialog
Returns a new instance of FindDialog.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tmis/interface/forms/find.rb', line 12 def initialize(entity, parent = nil) super parent @main = parent @ui = Ui::FindDialog.new @ui.setup_ui self @entity = entity case @entity when :lecturer @ui.findByLabel.text = "Фамилия преподавателя:" Lecturer.all.sort_by(&:surname).each{|x| @ui.findByComboBox.addItem(x.surname, x.id.to_v)} @ui.findByComboBox.setCurrentIndex(0) when :subject @ui.findByLabel.text = "Название предмета:" Subject.all.sort_by(&:title).each{|x| @ui.findByComboBox.addItem(x.title, x.id.to_v)} @ui.findByComboBox.setCurrentIndex(0) when :cabinet @ui.findByLabel.text = "Название кабинета:" Cabinet.all.sort_by(&:title).each{|x| @ui.findByComboBox.addItem(x.title, x.id.to_v)} @ui.findByComboBox.setCurrentIndex(0) else raise ArgumentError end connect(@ui..(Qt::DialogButtonBox::Ok), SIGNAL('clicked()')){ ok } connect(@ui..(Qt::DialogButtonBox::Cancel), SIGNAL('clicked()')){ cancel } end |
Instance Method Details
#cancel ⇒ Object
59 60 61 62 63 64 |
# File 'lib/tmis/interface/forms/find.rb', line 59 def cancel @main.study_table_models.each do |model| model.cancelColoring end close end |
#ok ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tmis/interface/forms/find.rb', line 38 def ok @main.study_table_models.each do |model| model.cancelColoring end case @entity when :lecturer studies = Study.where(lecturer_id: @ui.findByComboBox.itemData(@ui.findByComboBox.currentIndex).to_i) when :subject studies = Study.where(subject_id: @ui.findByComboBox.itemData(@ui.findByComboBox.currentIndex).to_i) when :cabinet studies = Study.where(cabinet_id: @ui.findByComboBox.itemData(@ui.findByComboBox.currentIndex).to_i) else raise ArgumentError end studies.each do |study| @main.study_table_models.each do |model| model.setColor(study.id, Qt::green) end end end |
#show_message(text) ⇒ Object
66 67 68 69 70 |
# File 'lib/tmis/interface/forms/find.rb', line 66 def (text) box = Qt::MessageBox.new box.setText text box.exec end |