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
qqmlsorterbase.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
/
qqmlsorterbase_p
.
h
>
6
#
include
<
QtQmlModels
/
private
/
qqmlsortfilterproxymodel_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmltype Sorter
12
\inherits QtObject
13
\inqmlmodule QtQml.Models
14
\since 6.10
15
\preliminary
16
\brief Abstract base type providing functionality common to sorters.
17
18
Sorter provides a set of common properties for all the sorters that they
19
inherit from.
20
*/
21
22
QQmlSorterBase::QQmlSorterBase(QQmlSorterBasePrivate *privObj, QObject *parent)
23
: QObject (*privObj, parent)
24
{
25
}
26
27
/*!
28
\qmlproperty bool Sorter::enabled
29
30
This property enables the \l SortFilterProxyModel to consider this sorter
31
while sorting the model data.
32
33
The default value is \c true.
34
*/
35
bool
QQmlSorterBase::enabled()
const
36
{
37
Q_D(
const
QQmlSorterBase);
38
return
d->m_enabled;
39
40
}
41
42
void
QQmlSorterBase::setEnabled(
const
bool
enabled)
43
{
44
Q_D(QQmlSorterBase);
45
if
(d->m_enabled == enabled)
46
return
;
47
d->m_enabled = enabled;
48
invalidate(
true
);
49
emit enabledChanged();
50
}
51
52
/*!
53
\qmlproperty Qt::SortOrder Sorter::sortOrder
54
55
This property holds the order used by \l SortFilterProxyModel when sorting
56
the model data.
57
58
The default value is \c Qt::AscendingOrder.
59
*/
60
Qt::SortOrder QQmlSorterBase::sortOrder()
const
61
{
62
Q_D(
const
QQmlSorterBase);
63
return
d->m_sortOrder;
64
}
65
66
void
QQmlSorterBase::setSortOrder(
const
Qt::SortOrder sortOrder)
67
{
68
Q_D(QQmlSorterBase);
69
if
(d->m_sortOrder == sortOrder)
70
return
;
71
d->m_sortOrder = sortOrder;
72
invalidate();
73
emit sortOrderChanged();
74
}
75
76
/*!
77
\qmlproperty int Sorter::priority
78
79
This property holds the priority that is given to this sorter compared to
80
other sorters. The lesser value results in a higher priority and the higher
81
value results in a lower priority.
82
83
The default value is \c -1.
84
*/
85
int
QQmlSorterBase::priority()
const
86
{
87
Q_D(
const
QQmlSorterBase);
88
return
d->m_sorterPriority;
89
}
90
91
void
QQmlSorterBase::setPriority(
const
int
priority)
92
{
93
Q_D(QQmlSorterBase);
94
if
(d->m_sorterPriority == priority)
95
return
;
96
d->m_sorterPriority = priority;
97
invalidate(
true
);
98
emit priorityChanged();
99
}
100
101
/*!
102
\qmlproperty int Sorter::column
103
104
This property holds the column that this sorter is applied to.
105
106
The default value is \c 0.
107
*/
108
int
QQmlSorterBase::column()
const
109
{
110
Q_D(
const
QQmlSorterBase);
111
return
d->m_sortColumn;
112
}
113
114
void
QQmlSorterBase::setColumn(
const
int
column)
115
{
116
Q_D(QQmlSorterBase);
117
if
(d->m_sortColumn == column)
118
return
;
119
d->m_sortColumn = column;
120
invalidate();
121
emit columnChanged();
122
}
123
124
/*!
125
\internal
126
*/
127
void
QQmlSorterBase::invalidate(
bool
updateCache)
128
{
129
// Update the cached filters and invalidate the model
130
if
(updateCache)
131
emit invalidateCache(
this
);
132
emit invalidateModel();
133
}
134
135
QT_END_NAMESPACE
136
137
#
include
"moc_qqmlsorterbase_p.cpp"
qtdeclarative
src
qmlmodels
sfpm
sorters
qqmlsorterbase.cpp
Generated on
for Qt by
1.16.1