Class: MainWindow::EntityItemModel

Inherits:
Qt::AbstractItemModel
  • Object
show all
Defined in:
lib/tmis/interface/mainwindow.rb

Overview

def groupAndSubgroup

date = Date.parse(@ui.dateDateEdit.date.toString(Qt::ISODate))
dates = date.monday..date.monday + 6
v = Verificator.new(dates)
res = v.verify(:group_and_subgroup).map do |k, v|
  date = k[0]
  lecturer = Lecturer.where(id: k[1]).first
  number = k[2]
  if lecturer.stub
    nil
  else
    v.each{ |study| @study_table_models[date.cwday - 1].setColor(study.id Qt::red) }
    "#{date} | #{lecturer} ведёт несколько пар одновременно! Номер пары: #{number}"
  end
end

end

def on_verifyGroupAndSubgroup

@console.browser.clear
@console.show
@console.browser.append groupAndSubgroup

end

Instance Method Summary collapse

Constructor Details

#initialize(lambda, parent = nil) ⇒ EntityItemModel

Returns a new instance of EntityItemModel.



532
533
534
535
536
537
# File 'lib/tmis/interface/mainwindow.rb', line 532

def initialize(lambda, parent = nil)
  super(parent)
  @get_entities = lambda
  @entities = @get_entities.()
  @size = @entities.size
end

Instance Method Details

#columnCount(parent = self) ⇒ Object



553
554
555
# File 'lib/tmis/interface/mainwindow.rb', line 553

def columnCount(parent = self)
  1
end

#data(index, role = Qt::DisplayRole, data = nil) ⇒ Object



561
562
563
564
565
566
567
# File 'lib/tmis/interface/mainwindow.rb', line 561

def data(index, role = Qt::DisplayRole, data = nil)
  if role == Qt::DisplayRole && index.valid?
    @entities[index.row].to_s.to_v
  else
    Qt::Variant.new
  end
end

#flags(index) ⇒ Object



569
570
571
572
573
574
575
# File 'lib/tmis/interface/mainwindow.rb', line 569

def flags(index)
  if index.valid?
    Qt::ItemIsDragEnabled | super(index)
  else
    super(index)
  end
end

#index(row, column, parent) ⇒ Object



545
546
547
# File 'lib/tmis/interface/mainwindow.rb', line 545

def index(row, column, parent)
  createIndex(row, column)
end

#mimeData(indexes) ⇒ Object



577
578
579
580
581
582
583
584
# File 'lib/tmis/interface/mainwindow.rb', line 577

def mimeData(indexes)
  entity = @entities[indexes.first.row]
  ba = Qt::ByteArray.new entity.id.to_s # Marshal.dump entity?
  mime_type = "application/#{entity.class.to_s.downcase}"
  mime_data = super indexes # для обхода ошибки сегментации Qt::MimeData создаётся с помощью родительского метода
  mime_data.setData(mime_type, ba)
  mime_data
end

#parent(index) ⇒ Object



549
550
551
# File 'lib/tmis/interface/mainwindow.rb', line 549

def parent(index)
  Qt::ModelIndex.new()
end

#refreshObject



539
540
541
542
543
# File 'lib/tmis/interface/mainwindow.rb', line 539

def refresh
  @entities = @get_entities.()
  @size = @entities.size
  emit layoutChanged()
end

#rowCount(parent = self) ⇒ Object



557
558
559
# File 'lib/tmis/interface/mainwindow.rb', line 557

def rowCount(parent = self)
  @size
end