| qqmlfunctionsorter.cpp |
!
\qmltype FunctionSorter
\inherits Sorter
\inqmlmodule QtQml.Models
\since 6.10
\preliminary
\brief Sorts data in a \l SortFilterProxyModel based on the evaluation of
the designated 'compare' method.
FunctionSorter allows user to define the designated 'compare' method and it
will be evaluated to sort the data. The method takes two arguments
(lhs and rhs) of the specified parameter type and the data can
be accessed as below for evaluation,
\qml
SortFilterProxyModel {
sourceModel: model
sorters: [
FunctionSorter {
id: functionSorter
component RoleData: QtObject {
property real age
}
function compare(lhsData: RoleData, rhsData: RoleData) : int {
return (lhsData.age < rhsData.age) ? -1 : ((lhsData === rhsData.age) ? 0 : 1)
}
}
]
}
\endqml
\warning Both parameters of the \c compare method must carry an explicit
type annotation, as \c lhsData and \c rhsData do in the example above, and
both annotations must resolve to the same type. The \c compare method written
the ordinary JavaScript way, without parameter type annotations, e.g.
\c{function compare(lhsData, rhsData) : int { ... }}, compiles without
any warning but fails with comparision. \l FunctionSorter relies on the annotated
type to know what kind of role-data object to instantiate and populate for
\c lhsData and \c rhsData; without it, there is nothing to instantiate.
\note \deprecated [6.12] The \c sort method is deprecated. Rename it to \c compare.
\note The \c compare function must have exactly two explicitly type-annotated
parameters of matching types and an explicit \c{: int} return type. If these
requirements are not met, the sorter emits a warning and returns early.
\note The user needs to explicitly invoke
\l{SortFilterProxyModel::invalidateSorter} whenever any external qml
property used within the designated 'compare' method changes. This behaviour
is subject to change in the future, like implicit invalidation and thus the
user doesn't need to explicitly invoke
\l{SortFilterProxyModel::invalidateSorter}.
|
8901 |
- |
| qqmlfunctionsorter_p.h |
|
1551 |
- |
| qqmlrolesorter.cpp |
!
\qmltype RoleSorter
\inherits Sorter
\inqmlmodule QtQml.Models
\since 6.10
\preliminary
\brief Sort data in a \l SortFilterProxyModel based on configured role
name.
RoleSorter allows the user to sort the data according to the role name
as configured in the source model.
The RoleSorter can be configured in the sort filter proxy model as below,
\qml
SortFilterProxyModel {
sourceModel: model
sorters: [
RoleSorter { roleName: "firstname" }
]
}
\endqml
|
2624 |
- |
| qqmlrolesorter_p.h |
|
1692 |
- |
| qqmlsorterbase.cpp |
!
\qmltype Sorter
\inherits QtObject
\inqmlmodule QtQml.Models
\since 6.10
\preliminary
\brief Abstract base type providing functionality common to sorters.
Sorter provides a set of common properties for all the sorters that they
inherit from.
|
3094 |
- |
| qqmlsorterbase_p.h |
do nothing |
2630 |
- |
| qqmlsortercompositor.cpp |
|
8934 |
- |
| qqmlsortercompositor_p.h |
|
2566 |
- |
| qqmlstringsorter.cpp |
!
\qmltype StringSorter
\inherits Sorter
\inqmlmodule QtQml.Models
\since 6.10
\preliminary
\brief Sort data in a \l SortFilterProxyModel based on ordering of the
locale.
StringSorter allows the user to sort the data according to the role name
as configured in the source model. StringSorter compares strings according
to a localized collation algorithm.
The StringSorter can be configured in the sort filter proxy model as below,
\qml
SortFilterProxyModel {
sourceModel: model
sorters: [
StringSorter { roleName: "name" }
]
}
\endqml
|
4202 |
- |
| qqmlstringsorter_p.h |
|
2217 |
- |