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.



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

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

Instance Method Details

#columnCount(parent = self) ⇒ Object



551
552
553
# File 'lib/tmis/interface/mainwindow.rb', line 551

def columnCount(parent = self)
  1
end

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



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

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



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

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

#index(row, column, parent) ⇒ Object



543
544
545
# File 'lib/tmis/interface/mainwindow.rb', line 543

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

#mimeData(indexes) ⇒ Object



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

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



547
548
549
# File 'lib/tmis/interface/mainwindow.rb', line 547

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

#refreshObject



537
538
539
540
541
# File 'lib/tmis/interface/mainwindow.rb', line 537

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

#rowCount(parent = self) ⇒ Object



555
556
557
# File 'lib/tmis/interface/mainwindow.rb', line 555

def rowCount(parent = self)
  @size
end