1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.core.sortfilterproxymodel;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.abstractitemmodel;
19 import qt.core.abstractproxymodel;
20 import qt.core.itemselectionmodel;
21 import qt.core.mimedata;
22 import qt.core.namespace;
23 import qt.core.object;
24 import qt.core.regexp;
25 import qt.core.regularexpression;
26 import qt.core.size;
27 import qt.core.string;
28 import qt.core.stringlist;
29 import qt.core.variant;
30 import qt.helpers;
31 
32 /+ #if QT_CONFIG(regularexpression)
33 #endif
34 
35 QT_REQUIRE_CONFIG(sortfilterproxymodel); +/
36 
37 
38 
39 extern(C++, class) struct QSortFilterProxyModelPrivate;
40 extern(C++, class) struct QSortFilterProxyModelLessThan;
41 extern(C++, class) struct QSortFilterProxyModelGreaterThan;
42 
43 class /+ Q_CORE_EXPORT +/ QSortFilterProxyModel : QAbstractProxyModel
44 {
45 private:
46     /+ friend class QSortFilterProxyModelLessThan; +/
47     /+ friend class QSortFilterProxyModelGreaterThan; +/
48 
49     mixin(Q_OBJECT);
50     /+ Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
51 #if QT_CONFIG(regularexpression)
52     Q_PROPERTY(QRegularExpression filterRegularExpression READ filterRegularExpression WRITE setFilterRegularExpression)
53 #endif
54     Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
55     Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
56     Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity NOTIFY filterCaseSensitivityChanged)
57     Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity NOTIFY sortCaseSensitivityChanged)
58     Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware NOTIFY sortLocaleAwareChanged)
59     Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged)
60     Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged)
61     Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled NOTIFY recursiveFilteringEnabledChanged) +/
62 
63 public:
64     /+ explicit +/this(QObject parent = null);
65     ~this();
66 
67     override void setSourceModel(QAbstractItemModel sourceModel);
68 
69     override QModelIndex mapToSource(ref const(QModelIndex) proxyIndex) const;
70     override QModelIndex mapFromSource(ref const(QModelIndex) sourceIndex) const;
71 
72     override QItemSelection mapSelectionToSource(ref const(QItemSelection) proxySelection) const;
73     override QItemSelection mapSelectionFromSource(ref const(QItemSelection) sourceSelection) const;
74 
75     final QRegExp filterRegExp() const;
76 
77 /+ #if QT_CONFIG(regularexpression) +/
78     final QRegularExpression filterRegularExpression() const;
79 /+ #endif +/
80 
81     final int filterKeyColumn() const;
82     final void setFilterKeyColumn(int column);
83 
84     final /+ Qt:: +/qt.core.namespace.CaseSensitivity filterCaseSensitivity() const;
85     final void setFilterCaseSensitivity(/+ Qt:: +/qt.core.namespace.CaseSensitivity cs);
86 
87     final /+ Qt:: +/qt.core.namespace.CaseSensitivity sortCaseSensitivity() const;
88     final void setSortCaseSensitivity(/+ Qt:: +/qt.core.namespace.CaseSensitivity cs);
89 
90     final bool isSortLocaleAware() const;
91     final void setSortLocaleAware(bool on);
92 
93     final int sortColumn() const;
94     final /+ Qt:: +/qt.core.namespace.SortOrder sortOrder() const;
95 
96     final bool dynamicSortFilter() const;
97     final void setDynamicSortFilter(bool enable);
98 
99     final int sortRole() const;
100     final void setSortRole(int role);
101 
102     final int filterRole() const;
103     final void setFilterRole(int role);
104 
105     final bool isRecursiveFilteringEnabled() const;
106     final void setRecursiveFilteringEnabled(bool recursive);
107 
108 public /+ Q_SLOTS +/:
109     @QSlot final void setFilterRegExp(ref const(QString) pattern);
110     @QSlot final void setFilterRegExp(ref const(QRegExp) regExp);
111 /+ #if QT_CONFIG(regularexpression) +/
112     @QSlot final void setFilterRegularExpression(ref const(QString) pattern);
113     @QSlot final void setFilterRegularExpression(ref const(QRegularExpression) regularExpression);
114 /+ #endif +/
115     @QSlot final void setFilterWildcard(ref const(QString) pattern);
116     @QSlot final void setFilterFixedString(ref const(QString) pattern);
117 /+ #if QT_DEPRECATED_SINCE(5, 11) +/
118     /+ QT_DEPRECATED_X("Use QSortFilterProxyModel::invalidate") +/ @QSlot final void clear();
119 /+ #endif +/
120     @QSlot final void invalidate();
121 
122 protected:
123     /+ virtual +/ bool filterAcceptsRow(int source_row, ref const(QModelIndex) source_parent) const;
124     /+ virtual +/ bool filterAcceptsColumn(int source_column, ref const(QModelIndex) source_parent) const;
125     /+ virtual +/ bool lessThan(ref const(QModelIndex) source_left, ref const(QModelIndex) source_right) const;
126 
127 /+ #if QT_DEPRECATED_SINCE(5, 11) +/
128     /+ QT_DEPRECATED_X("Use QSortFilterProxyModel::invalidateFilter") +/ final void filterChanged();
129 /+ #endif +/
130     final void invalidateFilter();
131 
132 public:
133     /+ using QObject::parent; +/
134 
135     override QModelIndex index(int row, int column, ref const(QModelIndex) parent = globalInitVar!QModelIndex) const;
136     override QModelIndex parent(ref const(QModelIndex) child) const;
137     override QModelIndex sibling(int row, int column, ref const(QModelIndex) idx) const;
138 
139     override int rowCount(ref const(QModelIndex) parent = globalInitVar!QModelIndex) const;
140     override int columnCount(ref const(QModelIndex) parent = globalInitVar!QModelIndex) const;
141     override bool hasChildren(ref const(QModelIndex) parent = globalInitVar!QModelIndex) const;
142 
143     override QVariant data(ref const(QModelIndex) index, int role = /+ Qt:: +/qt.core.namespace.ItemDataRole.DisplayRole) const;
144     override bool setData(ref const(QModelIndex) index, ref const(QVariant) value, int role = /+ Qt:: +/qt.core.namespace.ItemDataRole.EditRole);
145 
146     override QVariant headerData(int section, /+ Qt:: +/qt.core.namespace.Orientation orientation, int role = /+ Qt:: +/qt.core.namespace.ItemDataRole.DisplayRole) const;
147     override bool setHeaderData(int section, /+ Qt:: +/qt.core.namespace.Orientation orientation,
148                 ref const(QVariant) value, int role = /+ Qt:: +/qt.core.namespace.ItemDataRole.EditRole);
149 
150     override QMimeData mimeData(ref const(QModelIndexList) indexes) const;
151     override bool dropMimeData(const(QMimeData) data, /+ Qt:: +/qt.core.namespace.DropAction action,
152                           int row, int column, ref const(QModelIndex) parent);
153 
154     override bool insertRows(int row, int count, ref const(QModelIndex) parent = globalInitVar!QModelIndex);
155     override bool insertColumns(int column, int count, ref const(QModelIndex) parent = globalInitVar!QModelIndex);
156     override bool removeRows(int row, int count, ref const(QModelIndex) parent = globalInitVar!QModelIndex);
157     override bool removeColumns(int column, int count, ref const(QModelIndex) parent = globalInitVar!QModelIndex);
158 
159     override void fetchMore(ref const(QModelIndex) parent);
160     override bool canFetchMore(ref const(QModelIndex) parent) const;
161     override /+ Qt:: +/qt.core.namespace.ItemFlags flags(ref const(QModelIndex) index) const;
162 
163     override QModelIndex buddy(ref const(QModelIndex) index) const;
164     override QModelIndexList match(ref const(QModelIndex) start, int role,
165                               ref const(QVariant) value, int hits = 1,
166                               /+ Qt:: +/qt.core.namespace.MatchFlags flags =
167                               /+ Qt:: +/qt.core.namespace.MatchFlags(/+ Qt:: +/qt.core.namespace.MatchFlag.MatchStartsWith|/+ Qt:: +/qt.core.namespace.MatchFlag.MatchWrap)) const;
168     override QSize span(ref const(QModelIndex) index) const;
169     override void sort(int column, /+ Qt:: +/qt.core.namespace.SortOrder order = /+ Qt:: +/qt.core.namespace.SortOrder.AscendingOrder);
170 
171     override QStringList mimeTypes() const;
172     override /+ Qt:: +/qt.core.namespace.DropActions supportedDropActions() const;
173 
174 /+ Q_SIGNALS +/public:
175     @QSignal final void dynamicSortFilterChanged(bool dynamicSortFilter);
176     @QSignal final void filterCaseSensitivityChanged(/+ Qt:: +/qt.core.namespace.CaseSensitivity filterCaseSensitivity);
177     @QSignal final void sortCaseSensitivityChanged(/+ Qt:: +/qt.core.namespace.CaseSensitivity sortCaseSensitivity);
178     @QSignal final void sortLocaleAwareChanged(bool sortLocaleAware);
179     @QSignal final void sortRoleChanged(int sortRole);
180     @QSignal final void filterRoleChanged(int filterRole);
181     @QSignal final void recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled);
182 
183 private:
184     /+ Q_DECLARE_PRIVATE(QSortFilterProxyModel) +/
185     /+ Q_DISABLE_COPY(QSortFilterProxyModel) +/
186 
187     /+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right, const QVector<int> &roles))
188     Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
189     Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
190     Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
191     Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
192     Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
193     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
194     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end))
195     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
196     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end))
197     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
198     Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
199     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
200     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end))
201     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
202     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end))
203     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
204     Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
205     Q_PRIVATE_SLOT(d_func(), void _q_clearMapping()) +/
206 }
207