Sha256: 9b7bd4ee089109ee173da7a232e48f90552f53b42571c3e2bc7e8c59f1163454

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require 'set'

require 'qtext/flags.rb'
require 'clevic/table_index.rb'
require 'clevic/qt/accept_reject'

# convenience methods
module Qt
  PasteRole = UserRole + 1 unless defined?( PasteRole )
  
  class AbstractItemDelegate
    # overridden in EntryDelegate subclasses
    def full_edit
    end
  end

  class KeyEvent
    def inspect
      "<Qt::KeyEvent text=#{text} key=#{key}"
    end
  end

  # This provides a bunch of methods to get easy access to the entity
  # and it's values directly from the index without having to keep
  # asking the model and jumping through other unncessary hoops
  class ModelIndex
    include Clevic::TableIndex
  end
  
  class ItemSelectionModel
    # return an array of integer indexes for currently selected rows
    def row_indexes
      selected_indexes.inject(Set.new) do |set,index|
        set << index.row
      end.to_a
    end

    # return a collection of selection ranges
    # in Qt this means an ItemSelection instance
    def ranges
      selection
    end
    
    def single_cell?
      ranges.size == 1 && ranges.first.single_cell?
    end
  end
  
  # implement accepted? and rejected? for TableView#confirm_dialog and friends
  class MessageBox
    include Clevic::AcceptReject
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clevic-0.13.0.b9 lib/clevic/qt/extensions.rb
clevic-0.13.0.b6 lib/clevic/qt/extensions.rb
clevic-0.13.0.b5 lib/clevic/qt/extensions.rb