Class: Ruber::OpenFileInProjectDlg::FilterModel

Inherits:
Qt::SortFilterProxyModel show all
Defined in:
lib/ruber/main_window/open_file_in_project_dlg.rb

Overview

Class implementing the filter for the OpenFileInProjectDlg class.

Instance Method Summary collapse

Methods inherited from Qt::SortFilterProxyModel

#each

Constructor Details

#initialize(parent = nil) ⇒ FilterModel

Returns a new FilterModel.

=====Arguments
_parent_:: the <tt>Qt::Object</tt> parent of the filter


58
59
60
61
62
# File 'lib/ruber/main_window/open_file_in_project_dlg.rb', line 58

def initialize parent = nil
  super
  @filter = nil
  @role = Qt::DisplayRole
end

Instance Method Details

#filter=(value) ⇒ Object

Changes the regexp used to filter the files, then re-applies the filter

calling the +invalidate+ method.
=====Arguments
_value_:: the new regexp. It can be +nil+ or a regexp. In the first case,
          the filter won't be applied.
=====TODO
On Windows, allow to also use the '\' character as pattern separator.
The problem is that that character is also the escape character in a regexp,
so things may become complicated.


75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ruber/main_window/open_file_in_project_dlg.rb', line 75

def filter= value
  @filter = value
  # TODO This doesn't work
  #on windows, where one can also use \ as separator. The problem is that in regexp
  #it's the escape character, so one must use something like
  #value.include?(File::SEPARATOR) || (File::ALT_SEPARATOR and value.match(/\\{2}))
  @role = if @filter and !value.source.include?(File::SEPARATOR) then Qt::UserRole + 1 
  else Qt::DisplayRole
  end
  invalidate
end