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
qqmlrolefilter.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
/
qqmlrolefilter_p
.
h
>
6
#
include
<
QtQmlModels
/
private
/
qqmlsortfilterproxymodel_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmltype RoleFilter
12
\inherits Filter
13
\inqmlmodule QtQml.Models
14
\since 6.10
15
\preliminary
16
\brief Abstract base type providing functionality to role-dependent filters.
17
*/
18
19
QQmlRoleFilter::QQmlRoleFilter(QObject *parent) :
20
QQmlFilterBase (
new
QQmlRoleFilterPrivate, parent)
21
{
22
}
23
24
QQmlRoleFilter::QQmlRoleFilter(QQmlFilterBasePrivate *priv, QObject *parent) :
25
QQmlFilterBase (priv, parent)
26
{
27
28
}
29
30
/*!
31
\qmlproperty string RoleFilter::roleName
32
33
This property holds the role name that will be used to filter the data.
34
35
The default value is the display role.
36
*/
37
const
QString& QQmlRoleFilter::roleName()
const
38
{
39
Q_D(
const
QQmlRoleFilter);
40
return
d->m_roleName;
41
}
42
43
void
QQmlRoleFilter::setRoleName(
const
QString& roleName)
44
{
45
Q_D(QQmlRoleFilter);
46
if
(d->m_roleName == roleName)
47
return
;
48
d->m_roleName = roleName;
49
emit roleNameChanged();
50
// Invalidate the model
51
invalidate();
52
}
53
54
/*!
55
\internal
56
*/
57
int
QQmlRoleFilter::itemRole(
const
QQmlSortFilterProxyModel *proxyModel)
const
58
{
59
Q_D(
const
QQmlRoleFilter);
60
if
(!d->m_roleName.isNull())
61
return
proxyModel->itemRoleForName(d->m_roleName);
62
return
-1;
63
}
64
65
QT_END_NAMESPACE
66
67
#
include
"moc_qqmlrolefilter_p.cpp"
qtdeclarative
src
qmlmodels
sfpm
filters
qqmlrolefilter.cpp
Generated on
for Qt by
1.16.1