SortFilterProxyModel QML Type

Filters and sorts data coming from a source QAbstractItemModel. More...

Import Statement: import SortFilterProxyModel .

Properties

Methods

Detailed Description

The SortFilterProxyModel type provides support for filtering and sorting data coming from a source model.

See also FilterContainer and SorterContainer.

Property Documentation

count : int

The number of rows in the proxy model (not filtered out the source model)


delayed : bool

Delay the execution of filters, sorters and proxyRoles until the next event loop. This can be used as an optimization when multiple filters, sorters or proxyRoles are changed in a single event loop. They will be executed once in a single batch at the next event loop instead of being executed in multiple sequential batches.

By default, the SortFilterProxyModel is not delayed, unless the SFPM_DELAYED environment variable is defined at compile time.


filters : list<Filter>

This property holds the list of filters for this proxy model. To be included in the model, a row of the source model has to be accepted by all the top level filters of this list.

See also Filter and FilterContainer.


proxyRoles : list<ProxyRole>

This property holds the list of proxy roles for this proxy model. Each proxy role adds a new custom role to the model.

See also ProxyRole.


sortRoleName : string

The role name of the source model's data used for the sorting.

See also sortRole and roleForName.


sorters : list<Sorter>

This property holds the list of sorters for this proxy model. The rows of the source model are sorted by the sorters of this list, in their order of insertion.

See also Sorter and SorterContainer.


sourceModel : QAbstractItemModel*

The source model of this proxy model


Method Documentation

variant get(row, string roleName)

Return the data for the given roleName of the item at row in the proxy model. This allows the role data to be read (not modified) from JavaScript. This equivalent to calling data(index(row, 0), roleForName(roleName)).


object get(row)

Return the item at row in the proxy model as a map of all its roles. This allows the item data to be read (not modified) from JavaScript.


int mapFromSource(sourceRow)

Returns the row in the SortFilterProxyModel given the sourceRow from the source model. Returns -1 if there is no corresponding row.


QModelIndex mapFromSource(sourceIndex)

Returns the model index in the SortFilterProxyModel given the sourceIndex from the source model.


int mapToSource(proxyRow)

Returns the source model row corresponding to the given proxyRow from the SortFilterProxyModel. Returns -1 if there is no corresponding row.


index mapToSource(proxyIndex)

Returns the source model index corresponding to the given proxyIndex from the SortFilterProxyModel.


int roleForName(roleName)

Returns the role number for the given roleName. If no role is found for this roleName, -1 is returned.