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