Method: MetaRuby::GUI::ModelSelector#map_index_from_source

Defined in:
lib/metaruby/gui/model_selector.rb

#map_index_from_source(source_index, reset_filter: true) ⇒ Qt::ModelIndex

Maps a model index from the source index to the filtered index, e.g. to select something in the view.

In addition to the normal map_from_source call, it allows to control whether the filter should be reset if the index given as parameter is currently filtered out

Parameters:

  • source_index (Qt::ModelIndex)

    an index valid in #browser_model

  • reset_filter (Boolean) (defaults to: true)

    if true, the filter is reset if the requested index is currently filtered out

Returns:



279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/metaruby/gui/model_selector.rb', line 279

def map_index_from_source(source_index, reset_filter: true)
    index = model_filter.map_from_source(source_index)
    if !index
        return
    elsif !index.valid?
        if !reset_filter
            return index
        end
        self.reset_filter
        model_filter.map_from_source(source_index)
    else index
    end
end