Class: FilteredFileTreeStore

Inherits:
ActiveWindow::FilteredActiveTreeStore show all
Defined in:
lib/filtered_file_tree_store.rb

Instance Attribute Summary

Attributes inherited from ActiveWindow::FilteredActiveTreeStore

#filter_string, #found_count, #unfiltered_store

Instance Method Summary collapse

Methods inherited from ActiveWindow::FilteredActiveTreeStore

#apply_filter, #clear_filter, #filtered?, inherited, #initialize, #set_visibility_for, #visibility_column

Methods included from ActiveWindow::TreeStoreExtentions

#add, #apply_to_tree, #get_object, included, #populate, #refresh

Constructor Details

This class inherits a constructor from ActiveWindow::FilteredActiveTreeStore

Instance Method Details

#filter=(new_filter_string) ⇒ Object



15
16
17
18
19
# File 'lib/filtered_file_tree_store.rb', line 15

def filter=(new_filter_string)
  @filter_regexp = nil
  @filter_column = nil
  super
end

#filter_columnObject



30
31
32
# File 'lib/filtered_file_tree_store.rb', line 30

def filter_column
  @filter_column ||= filter_string.index('/') ? FULL_PATH : NAME
end

#filter_regexpObject



22
23
24
25
26
27
28
# File 'lib/filtered_file_tree_store.rb', line 22

def filter_regexp
  @filter_regexp ||= Regexp.new(
    filter_string.split('/').map { |t| 
      Regexp.escape(t).split(//).join('.*') 
    }.join('.*/.*')
  )
end

#iter_visible?(iter) ⇒ Boolean

Fuzzy search by String ‘foo’ => matches la/lu/foo, f/lala/o/gaga/o ‘foo/bar’ => matches la/afoo/gnarz/barz, but not the above

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'lib/filtered_file_tree_store.rb', line 5

def iter_visible?(iter)
  case iter[OBJECT]
  when ListedDirectory; false
  when ListedFile
    iter[filter_column] =~ filter_regexp
  else
    false
  end
end