Sha256: b6058c4ac8847ae08cdf1ee721b56d32eb4cb88b8bc73af4e97ef33f58eb90ea

Contents?: true

Size: 996 Bytes

Versions: 10

Compression:

Stored size: 996 Bytes

Contents

require 'clevic/table_index.rb'
require 'gather'

module Clevic
  class SwingTableIndex
    include TableIndex
    include Gather

    def initialize( model, row, column )
      @model, @row, @column = model, row.to_i, column.to_i
    end
    attr_accessor :model
    property :row, :column

    def valid?
      row != -1 && column != -1 && model != nil
    end

    def self.invalid
      new( nil, -1, -1 )
    end

    def choppy( *args, &block  )
      return self unless self.valid?
      copied = clone.gather( *args, &block )

      # TODO this is mostly shared with Qt

      # convert a column name to a column index
      unless copied.column.is_a?( Numeric )
        copied.column = model.field_column( copied.column )
      end

      # return an invalid index if it's out of bounds,
      # or the copied index if it's OK.
      if copied.row >= model.row_count || copied.column >= model.column_count
        self.class.invalid
      else
        copied
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
clevic-0.14.6 lib/clevic/swing/swing_table_index.rb
clevic-0.14.5 lib/clevic/swing/swing_table_index.rb
clevic-0.14.4 lib/clevic/swing/swing_table_index.rb
clevic-0.14.3 lib/clevic/swing/swing_table_index.rb
clevic-0.14.2 lib/clevic/swing/swing_table_index.rb
clevic-0.14.1 lib/clevic/swing/swing_table_index.rb
clevic-0.14.0 lib/clevic/swing/swing_table_index.rb
clevic-0.13.0.b12 lib/clevic/swing/swing_table_index.rb
clevic-0.13.0.b11 lib/clevic/swing/swing_table_index.rb
clevic-0.13.0.b10 lib/clevic/swing/swing_table_index.rb