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