KSortFilterProxyModel QML Type
Filter and sort an existing QAbstractItemModel. More...
| Import Statement: | import org.kde.kitemmodels |
| In C++: | QSortFilterProxyModel |
Properties
- autoAcceptChildRows : bool
- count : int
- dynamicSortFilter : bool
- filterCaseSensitivity : Qt::CaseSensitivity
- filterColumnCallback : var
- filterKeyColumn : int
- filterRegularExpression : var
- filterRole : int
- filterRoleName : string
- filterRowCallback : var
- filterString : string
- isSortLocaleAware : bool
- recursiveFilteringEnabled : bool
- sortCaseSensitivity : Qt::CaseSensitivity
- sortColumn : int
- sortOrder : Qt::SortOrder
- sortRole : int
- sortRoleName : string
- sourceModel : var
Methods
- void invalidate()
- void invalidateFilter()
- QModelIndex mapFromSource(QModelIndex sourceIndex)
- QItemSelection mapSelectionFromSource(QItemSelection sourceSelection)
- QItemSelection mapSelectionToSource(QItemSelection proxySelection)
- QModelIndex mapToSource(QModelIndex proxyIndex)
- void setFilterFixedString(string pattern)
- void setFilterRegularExpression(string pattern)
- void setFilterRegularExpression(var regularExpression)
- void setFilterWildcard(string pattern)
Detailed Description
For example, filter and sort a list by its name role:
import QtQuick import org.kde.kitemmodels ListView { width: 200 height: 200 model: KSortFilterProxyModel { sourceModel: ListModel { ListElement { name: "Alice" } ListElement { name: "Bob" } ListElement { name: "Charlie" } } filterRoleName: "name" filterString: "li" filterCaseSensitivity: Qt.CaseInsensitive sortRoleName: "name" sortCaseSensitivity: Qt.CaseInsensitive sortColumn: 0 } delegate: Text { text: name } }
Property Documentation
autoAcceptChildRows : bool [default: false]
Whether all children of an accepted row remain visible, even if they do not match the filter themselves.
count : int
The number of top level rows.
dynamicSortFilter : bool [default: true]
Whether the proxy updates its sorting and filtering when sourceModel changes.
filterCaseSensitivity : Qt::CaseSensitivity [default: Qt.CaseSensitive]
The case sensitivity used when filtering strings.
filterColumnCallback : var
A JavaScript callable that can be used to perform advanced filters on a given column. The callback is passed the source column, and source parent for a given column as arguments.
See also filterRowCallback.
filterKeyColumn : int [default: 0]
The source column used for filtering. A value of -1 checks all columns.
filterRegularExpression : var
The regular expression used to filter source rows. Setting filterString replaces it with a fixed-string filter.
filterRole : int [default: Qt.DisplayRole]
The source role ID used for filtering. Setting this also updates filterRoleName.
filterRoleName : string
The name of the source role used for filtering. Use filterRole to set a numerical role ID instead.
filterRowCallback : var
A JavaScript callable that can be used to perform advanced filters on a given row. The callback is passed the source row, and source parent for a given row as arguments
The callable's return value is evaluated as boolean to determine whether the row is accepted (true) or filtered out (false). It overrides the default row filter, so filterString and filterRegularExpression have no effect while filterRowCallback is set. Attempts to write a non-callable to this property are silently ignored, but you can set it to null.
filterRowCallback: function(source_row, source_parent) {
return sourceModel.data(sourceModel.index(source_row, 0, source_parent), Qt.DisplayRole) == "...";
};
filterString : string
A fixed string used to filter rows by filterRole. Only matching rows are displayed.
isSortLocaleAware : bool [default: false]
Whether string sorting follows the current locale.
recursiveFilteringEnabled : bool [default: false]
Whether a parent remains visible when one of its descendants matches the filter.
sortCaseSensitivity : Qt::CaseSensitivity [default: Qt.CaseSensitive]
The case sensitivity used when sorting strings.
sortColumn : int [default: -1]
Specify which column should be used for sorting Setting sortRoleName sorts column 0 if no column has been selected.
sortOrder : Qt::SortOrder
One of Qt.AscendingOrder or Qt.DescendingOrder
sortRole : int [default: Qt.DisplayRole]
The source role ID used for sorting. Setting this also updates sortRoleName.
sortRoleName : string
The name of the source role used for sorting. Use sortRole to set a numerical role ID instead. An empty name leaves rows unsorted.
sourceModel : var
The model whose rows are filtered and sorted.
Method Documentation
void invalidate()
Reapplies sorting and filtering to the source model.
void invalidateFilter()
Invalidates the current filtering.
This function should be called if you are implementing custom filtering through filterRowCallback or filterColumnCallback, and your filter parameters have changed.
QModelIndex mapFromSource(QModelIndex sourceIndex)
Returns the proxy model index corresponding to sourceIndex. A filtered-out item has no corresponding proxy index.
See also mapToSource().
QItemSelection mapSelectionFromSource(QItemSelection sourceSelection)
Returns the proxy model selection corresponding to sourceSelection.
QItemSelection mapSelectionToSource(QItemSelection proxySelection)
Returns the source model selection corresponding to proxySelection.
QModelIndex mapToSource(QModelIndex proxyIndex)
Returns the source model index corresponding to proxyIndex.
See also mapFromSource().
void setFilterFixedString(string pattern)
Filters rows using the literal string pattern.
void setFilterRegularExpression(string pattern)
Filters rows using the regular expression pattern.
void setFilterRegularExpression(var regularExpression)
Filters rows using regularExpression.
void setFilterWildcard(string pattern)
Filters rows using the wildcard pattern.