Sha256: faf72956676689784a9fc16af237b669088ba5386525195d2520ce63f62046f6

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

require 'Qt4'
require 'clevic/qt/ui/search_dialog_ui.rb'
require 'qtext/flags.rb'
require 'clevic/qt/accept_reject.rb'

module Clevic

  class SearchDialog
    include AcceptReject
    include QtFlags

    attr_reader :match_flags, :layout
    attr_accessor :result

    def initialize( parent )
      @layout = Ui_SearchDialog.new
      @dialog = Qt::Dialog.new
      @layout.setupUi( @dialog )
    end

    def from_start?
      layout.from_start.value
    end

    def from_start=( value )
      layout.from_start.value = value
    end

    def regex?
      layout.regex.value
    end

    def whole_words?
      layout.whole_words.value
    end

    def search_combo
      layout.search_combo
    end

    def forwards?
      layout.forwards.checked?
    end

    def backwards?
      layout.backwards.checked?
    end

    # return either :backwards or :forwards
    def direction
      return :forwards if forwards?
      return :backwards if backwards?
      raise "direction not known"
    end

    def exec( text = '' )
      search_combo.edit_text = text.to_s
      search_combo.set_focus
      self.result = @dialog.exec

      # remember previous searches
      if search_combo.find_text( search_combo.current_text ) == -1
        search_combo.add_item( search_combo.current_text )
      end

      self
    end

    def search_text
      search_combo.current_text
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

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