Class: Qt::StandardItemModel

Inherits:
Object
  • Object
show all
Includes:
QtEnumerable
Defined in:
lib/ruber/qt_sugar.rb

Instance Method Summary collapse

Instance Method Details

#eachObject

If given a block, calls it once for each top level item. This means that items in the same row but in different columns will each cause a separate block execution.

If a block isn’t given, returns an Enumerator which does the same as above.



467
468
469
470
471
472
473
474
475
476
477
# File 'lib/ruber/qt_sugar.rb', line 467

def each
  if block_given?
    rowCount.times do |i|
      columnCount.times do |j| 
        it = item(i,j)
        yield it if it
      end
    end
  else self.to_enum
  end
end

#each_rowObject

If given a block, calls it once for each top level row, passing it an array containing the items in the row. If the number of columns varies from row to row, the arrays corresponding to the ones with less items will have nil instead of the missing items.

If a block isn’t given, returns an Enumerator which does the same as above.



487
488
489
490
491
492
493
494
495
496
# File 'lib/ruber/qt_sugar.rb', line 487

def each_row
  if block_given?
    rowCount.times do |r|
      a = [] 
      columnCount.times{|c| a << item(r, c)}
      yield a
    end
  else self.to_enum(:each_row)
  end
end