Class: Ruber::FilteredOutputWidget::FilterModel

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

Overview

Filter model derived from Qt::SortFilterProxyModel which better integrate with FilteredOutputWidget.

The differences between this class and Qt::SortFilterProxyModel are the following

  • it has the ability to ignore the filter (see FilteredOutputWidget)

  • it provides an easy way to always accept some kind of items (see exclude and

exclude_from_filtering?)

  • it emits a signal when the filter reg exp is changed

Note: this class is meant to be used with a regexp filter, not with a string filter.

Signals

filter_changed(QString reg)

Signal emitted when the regexp used for filtering changes (including when the filter is removed). reg is a string containing the source of the regexp.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Qt::SortFilterProxyModel

#each

Constructor Details

#initialize(parent = nil, exclude = nil) ⇒ FilterModel

Creates a new FilterModel.

parent is the parent object, while exclude is the initial value of the exclude attribute (which can be changed later).



265
266
267
268
269
# File 'lib/ruber/filtered_output_widget.rb', line 265

def initialize parent = nil, exclude = nil
  super parent
  @exclude = exclude
  @ignore_filter = false
end

Instance Attribute Details

#excludeObject

The kind of items to exclude from filtering. See exclude_from_filtering?



257
258
259
# File 'lib/ruber/filtered_output_widget.rb', line 257

def exclude
  @exclude
end

Instance Method Details

#filter_ignored?Boolean

Tells whether the object has been instructed to ignore the filter

Returns:

  • (Boolean)


274
275
276
# File 'lib/ruber/filtered_output_widget.rb', line 274

def filter_ignored?
  @ignore_filter
end

#filter_reg_exp=(str) ⇒ Object

Override of Qt::SortFilterProxyModel#filter_reg_exp= which, after changing the regexp ( and invalidating the model) emits the filter_changed(QString) signal



291
292
293
294
# File 'lib/ruber/filtered_output_widget.rb', line 291

def filter_reg_exp= str
  super
  emit filter_changed(str)
end

#ignore_filter=(val) ⇒ Object

Instructs the model to ignore or not the filter, according to val. This method always invalidate the model



282
283
284
285
# File 'lib/ruber/filtered_output_widget.rb', line 282

def ignore_filter= val
  @ignore_filter = val
  invalidate
end