Sha256: f4ba8e65a869bd74ca408e1dcb2a9ce9c1f5db19a5e00854e2992b591f535c0a

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 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

  # make sure that to_variant doesn't wrap
  # an existing variant inside another variant.
  class Variant
    def to_variant
      self
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clevic-0.14.6 lib/clevic/qt/extensions.rb
clevic-0.14.5 lib/clevic/qt/extensions.rb
clevic-0.14.4 lib/clevic/qt/extensions.rb
clevic-0.14.3 lib/clevic/qt/extensions.rb
clevic-0.14.2 lib/clevic/qt/extensions.rb
clevic-0.14.1 lib/clevic/qt/extensions.rb
clevic-0.14.0 lib/clevic/qt/extensions.rb