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
qqmlfilterbase.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/qqmlsortfilterproxymodel_p.h>
5#include <QtQmlModels/private/qqmlfilterbase_p.h>
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \qmltype Filter
11 \inherits QtObject
12 \inqmlmodule QtQml.Models
13 \since 6.10
14 \preliminary
15 \brief Abstract base type providing functionality common to filters.
16
17 Filter provides a set of common properties for all the filters that they
18 inherit from.
19*/
20
21QQmlFilterBase::QQmlFilterBase(QQmlFilterBasePrivate *privObj, QObject *parent)
22 : QObject (*privObj, parent)
23{
24}
25
26/*!
27 \qmlproperty bool Filter::enabled
28
29 This property enables the \l SortFilterProxyModel to consider this filter
30 while filtering the model data.
31
32 The default value is \c true.
33*/
34bool QQmlFilterBase::enabled() const
35{
36 Q_D(const QQmlFilterBase);
37 return d->m_enabled;
38}
39
40void QQmlFilterBase::setEnabled(const bool enabled)
41{
42 Q_D(QQmlFilterBase);
43 if (d->m_enabled == enabled)
44 return;
45 d->m_enabled = enabled;
46 invalidate(true);
47 emit enabledChanged();
48}
49
50/*!
51 \qmlproperty bool Filter::inverted
52
53 This property inverts the filter, causing the data that would normally be
54 filtered out to be presented instead.
55
56 The default value is \c false.
57*/
58bool QQmlFilterBase::isInverted() const
59{
60 Q_D(const QQmlFilterBase);
61 return d->m_inverted;
62}
63
64void QQmlFilterBase::setInverted(const bool invert)
65{
66 Q_D(QQmlFilterBase);
67 if (d->m_inverted == invert)
68 return;
69 d->m_inverted = invert;
70 invalidate();
71 emit invertedChanged();
72}
73
74/*!
75 \qmlproperty int Filter::column
76
77 This property specifies which column in the model the filter should be
78 applied on. If the value is \c -1, the filter will be applied to all
79 the columns in the model.
80
81 The default value is \c -1.
82*/
83int QQmlFilterBase::column() const
84{
85 Q_D(const QQmlFilterBase);
86 return d->m_filterColumn;
87}
88
89void QQmlFilterBase::setColumn(const int column)
90{
91 Q_D(QQmlFilterBase);
92 if (d->m_filterColumn == column)
93 return;
94 d->m_filterColumn = column;
95 invalidate();
96 emit columnChanged();
97}
98
99/*!
100 \internal
101*/
102void QQmlFilterBase::invalidate(bool updateCache)
103{
104 // Update the cached filters and invalidate the model
105 if (updateCache)
106 emit invalidateCache(this);
107 emit invalidateModel();
108}
109
110QT_END_NAMESPACE
111
112#include "moc_qqmlfilterbase_p.cpp"