Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlalloffilter.cpp
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
<
QtQmlModels
/
private
/
qqmlalloffilter_p
.
h
>
6
#
include
<
QtQmlModels
/
private
/
qqmlsortfilterproxymodel_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmltype AllOfFilter
12
\inherits FilterBase
13
\inqmlmodule QtQml.Models
14
\since 6.12
15
\preliminary
16
\brief Combines multiple filters using logical AND in a
17
\l SortFilterProxyModel.
18
19
AllOfFilter groups a set of child filters and finds a matching row or
20
column only when all child filters accept it. It is equivalent to applying
21
multiple filters directly to \l SortFilterProxyModel, but allows the
22
group itself to be enabled, disabled, or inverted as a single unit.
23
24
The following snippet shows how AllOfFilter can be used to include
25
only rows where \c status is \c "active" and \c favorite is \c true:
26
27
\qml
28
SortFilterProxyModel {
29
sourceModel: model
30
filters: [
31
AllOfFilter {
32
ValueFilter {
33
roleName: "parent";
34
value: "root"
35
}
36
ValueFilter {
37
roleName: "status";
38
value: "active"
39
}
40
}
41
]
42
}
43
\endqml
44
*/
45
46
/*!
47
\qmlproperty list<Filter> AllOfFilter::filters
48
49
The list of child filters evaluated with logical AND. A row is accepted
50
if all the filters in this list accepts it.
51
52
This is the default property, so filters can be declared as direct
53
children without the \c filters keyword:
54
55
\qml
56
AllOfFilter {
57
ValueFilter { roleName: "status"; value: "active" }
58
ValueFilter { roleName: "parent"; value: "root" }
59
}
60
\endqml
61
*/
62
63
QQmlAllOfFilter::QQmlAllOfFilter(QObject *parent) :
64
QQmlCompositeFilterBase(
new
QQmlAllOfFilterPrivate, parent)
65
{
66
67
}
68
69
/*!
70
\internal
71
*/
72
bool
QQmlAllOfFilter::filterAcceptsRowInternal(
int
row,
const
QModelIndex& sourceParent,
const
QQmlSortFilterProxyModel *proxyModel)
const
73
{
74
// Note: QQmlFilterCompositor evaluates rows using std::all_of (AND logic),
75
// which matches AllOf semantics exactly, so no override needed.
76
return
QQmlCompositeFilterBase::filterAcceptsRowInternal(row, sourceParent, proxyModel);
77
}
78
79
bool
QQmlAllOfFilter::filterAcceptsColumnInternal(
int
column,
const
QModelIndex& sourceParent,
const
QQmlSortFilterProxyModel *proxyModel)
const
80
{
81
// Note: QQmlFilterCompositor evaluates rows using std::all_of (AND logic),
82
// which matches AllOf semantics exactly, so no override needed.
83
return
QQmlCompositeFilterBase::filterAcceptsColumnInternal(column, sourceParent, proxyModel);
84
}
85
86
QT_END_NAMESPACE
87
88
#
include
"moc_qqmlalloffilter_p.cpp"
qtdeclarative
src
qmlmodels
sfpm
filters
qqmlalloffilter.cpp
Generated on
for Qt by
1.16.1