Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsortfilterproxymodel.h
Go to the documentation of this file.
1// Copyright (C) 2016 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#ifndef QSORTFILTERPROXYMODEL_H
5#define QSORTFILTERPROXYMODEL_H
6
7#include <QtCore/qabstractproxymodel.h>
8
9#include <QtCore/qregularexpression.h>
10
11QT_REQUIRE_CONFIG(sortfilterproxymodel);
12
14
15
19
20class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
21{
24
26 Q_PROPERTY(QRegularExpression filterRegularExpression READ filterRegularExpression
27 WRITE setFilterRegularExpression BINDABLE bindableFilterRegularExpression)
28 Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn
29 BINDABLE bindableFilterKeyColumn)
30 Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter
31 BINDABLE bindableDynamicSortFilter)
32 Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity
33 WRITE setFilterCaseSensitivity NOTIFY filterCaseSensitivityChanged
34 BINDABLE bindableFilterCaseSensitivity)
35 Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity
36 WRITE setSortCaseSensitivity NOTIFY sortCaseSensitivityChanged
37 BINDABLE bindableSortCaseSensitivity)
38 Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware
39 NOTIFY sortLocaleAwareChanged BINDABLE bindableIsSortLocaleAware)
40 Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged
41 BINDABLE bindableSortRole)
42 Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged
43 BINDABLE bindableFilterRole)
44 Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled
45 WRITE setRecursiveFilteringEnabled NOTIFY recursiveFilteringEnabledChanged
46 BINDABLE bindableRecursiveFilteringEnabled)
47 Q_PROPERTY(bool autoAcceptChildRows READ autoAcceptChildRows WRITE setAutoAcceptChildRows
48 NOTIFY autoAcceptChildRowsChanged BINDABLE bindableAutoAcceptChildRows)
49
50public:
51 explicit QSortFilterProxyModel(QObject *parent = nullptr);
53
54 void setSourceModel(QAbstractItemModel *sourceModel) override;
55
56 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
57 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
58
59 QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const override;
60 QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const override;
61
62 QRegularExpression filterRegularExpression() const;
63 QBindable<QRegularExpression> bindableFilterRegularExpression();
64
65 int filterKeyColumn() const;
66 void setFilterKeyColumn(int column);
67 QBindable<int> bindableFilterKeyColumn();
68
69 Qt::CaseSensitivity filterCaseSensitivity() const;
70 void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
71 QBindable<Qt::CaseSensitivity> bindableFilterCaseSensitivity();
72
73 Qt::CaseSensitivity sortCaseSensitivity() const;
74 void setSortCaseSensitivity(Qt::CaseSensitivity cs);
75 QBindable<Qt::CaseSensitivity> bindableSortCaseSensitivity();
76
77 bool isSortLocaleAware() const;
78 void setSortLocaleAware(bool on);
79 QBindable<bool> bindableIsSortLocaleAware();
80
81 int sortColumn() const;
82 Qt::SortOrder sortOrder() const;
83
84 bool dynamicSortFilter() const;
85 void setDynamicSortFilter(bool enable);
86 QBindable<bool> bindableDynamicSortFilter();
87
88 int sortRole() const;
89 void setSortRole(int role);
90 QBindable<int> bindableSortRole();
91
92 int filterRole() const;
93 void setFilterRole(int role);
94 QBindable<int> bindableFilterRole();
95
96 bool isRecursiveFilteringEnabled() const;
97 void setRecursiveFilteringEnabled(bool recursive);
98 QBindable<bool> bindableRecursiveFilteringEnabled();
99
100 bool autoAcceptChildRows() const;
101 void setAutoAcceptChildRows(bool accept);
102 QBindable<bool> bindableAutoAcceptChildRows();
103
104public Q_SLOTS:
105 void setFilterRegularExpression(const QString &pattern);
106 void setFilterRegularExpression(const QRegularExpression &regularExpression);
107 void setFilterWildcard(const QString &pattern);
108 void setFilterFixedString(const QString &pattern);
109 void invalidate();
110
111protected:
112 virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
113 virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
114 virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
115
116 void invalidateFilter();
117 void invalidateRowsFilter();
118 void invalidateColumnsFilter();
119
120public:
121 using QObject::parent;
122
123 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
124 QModelIndex parent(const QModelIndex &child) const override;
125 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
126
127 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
128 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
129 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
130
131 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
132 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
133
134 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
135 bool setHeaderData(int section, Qt::Orientation orientation,
136 const QVariant &value, int role = Qt::EditRole) override;
137
138 QMimeData *mimeData(const QModelIndexList &indexes) const override;
139 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
140 int row, int column, const QModelIndex &parent) override;
141
142 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
143 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
144 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
145 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
146
147 void fetchMore(const QModelIndex &parent) override;
148 bool canFetchMore(const QModelIndex &parent) const override;
149 Qt::ItemFlags flags(const QModelIndex &index) const override;
150
151 QModelIndex buddy(const QModelIndex &index) const override;
152 QModelIndexList match(const QModelIndex &start, int role,
153 const QVariant &value, int hits = 1,
154 Qt::MatchFlags flags =
155 Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override;
156 QSize span(const QModelIndex &index) const override;
157 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
158
159 QStringList mimeTypes() const override;
160 Qt::DropActions supportedDropActions() const override;
161
163 void dynamicSortFilterChanged(bool dynamicSortFilter);
164 void filterCaseSensitivityChanged(Qt::CaseSensitivity filterCaseSensitivity);
165 void sortCaseSensitivityChanged(Qt::CaseSensitivity sortCaseSensitivity);
166 void sortLocaleAwareChanged(bool sortLocaleAware);
167 void sortRoleChanged(int sortRole);
168 void filterRoleChanged(int filterRole);
169 void recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled);
170 void autoAcceptChildRowsChanged(bool autoAcceptChildRows);
171
172private:
173 Q_DECLARE_PRIVATE(QSortFilterProxyModel)
174 Q_DISABLE_COPY(QSortFilterProxyModel)
175};
176
178
179#endif // QSORTFILTERPROXYMODEL_H
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
\inmodule QtCore
Definition qproperty.h:811
\inmodule QtCore
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore \reentrant
\inmodule QtCore
Definition qsize.h:25
The QSortFilterProxyModel class provides support for sorting and filtering data passed between anothe...
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
Definition qcompare.h:63
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLbitfield flags
GLboolean enable
GLuint start
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
GLfixed GLfixed GLint GLint order
GLubyte * pattern
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
static bool match(const uchar *found, uint foundLen, const char *target, uint targetLen)
static bool lessThan(const QChar *a, int l, const char *c)
Definition qurlidna.cpp:321
#define explicit
model setHeaderData(0, Qt::Horizontal, tr("Name"))
mimeData setData("text/csv", csvData)
QMimeData * mimeData
QLayoutItem * child
[0]