1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the test suite of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef TST_QSORTFILTERPROXYMODEL_H |
30 | #define TST_QSORTFILTERPROXYMODEL_H |
31 | |
32 | #include "dynamictreemodel.h" |
33 | #include <QLoggingCategory> |
34 | #include <QSortFilterProxyModel> |
35 | #include <QStandardItemModel> |
36 | |
37 | enum class FilterType { |
38 | RegExp, |
39 | RegularExpression |
40 | }; |
41 | |
42 | Q_DECLARE_METATYPE(QList<QPersistentModelIndex>) |
43 | |
44 | class tst_QSortFilterProxyModel : public QObject |
45 | { |
46 | Q_OBJECT |
47 | public slots: |
48 | void initTestCase(); |
49 | void cleanupTestCase(); |
50 | void cleanup(); |
51 | |
52 | private slots: |
53 | void getSetCheck(); |
54 | void sort_data(); |
55 | void sort(); |
56 | void sortHierarchy_data(); |
57 | void sortHierarchy(); |
58 | |
59 | void insertRows_data(); |
60 | void insertRows(); |
61 | void prependRow(); |
62 | void appendRowFromCombobox_data(); |
63 | void appendRowFromCombobox(); |
64 | void removeRows_data(); |
65 | void removeRows(); |
66 | void removeColumns_data(); |
67 | void removeColumns(); |
68 | void insertAfterSelect(); |
69 | void removeAfterSelect(); |
70 | void filter_data(); |
71 | void filter(); |
72 | void filterHierarchy_data(); |
73 | void filterHierarchy(); |
74 | void filterColumns_data(); |
75 | void filterColumns(); |
76 | |
77 | void filterTable(); |
78 | void filterCurrent(); |
79 | void filter_qtbug30662(); |
80 | |
81 | void changeSourceLayout(); |
82 | void changeSourceLayoutFilteredOut(); |
83 | void removeSourceRows_data(); |
84 | void removeSourceRows(); |
85 | void insertSourceRows_data(); |
86 | void insertSourceRows(); |
87 | void changeFilter_data(); |
88 | void changeFilter(); |
89 | void changeSourceData_data(); |
90 | void changeSourceData(); |
91 | void changeSourceDataKeepsStableSorting_qtbug1548(); |
92 | void changeSourceDataForwardsRoles_qtbug35440(); |
93 | void changeSourceDataProxySendDataChanged_qtbug87781(); |
94 | void changeSourceDataTreeModel(); |
95 | void changeSourceDataProxyFilterSingleColumn(); |
96 | void changeSourceDataProxyFilterMultipleColumns(); |
97 | void resortingDoesNotBreakTreeModels(); |
98 | void dynamicFilterWithoutSort(); |
99 | void sortFilterRole(); |
100 | void selectionFilteredOut(); |
101 | void match_data(); |
102 | void match(); |
103 | void matchTree(); |
104 | void insertIntoChildrenlessItem(); |
105 | void invalidateMappedChildren(); |
106 | void insertRowIntoFilteredParent(); |
107 | void filterOutParentAndFilterInChild(); |
108 | |
109 | void sourceInsertRows(); |
110 | void sourceModelDeletion(); |
111 | |
112 | void sortColumnTracking1(); |
113 | void sortColumnTracking2(); |
114 | |
115 | void sortStable(); |
116 | |
117 | void hiddenColumns(); |
118 | void insertRowsSort(); |
119 | void staticSorting(); |
120 | void dynamicSorting(); |
121 | void fetchMore(); |
122 | void hiddenChildren(); |
123 | void mapFromToSource(); |
124 | void removeRowsRecursive(); |
125 | void doubleProxySelectionSetSourceModel(); |
126 | void appearsAndSort(); |
127 | void unnecessaryDynamicSorting(); |
128 | void unnecessaryMapCreation(); |
129 | void resetInvalidate_data(); |
130 | void resetInvalidate(); |
131 | |
132 | void testMultipleProxiesWithSelection(); |
133 | void mapSelectionFromSource(); |
134 | void testResetInternalData(); |
135 | void filteredColumns(); |
136 | void (); |
137 | |
138 | void testParentLayoutChanged(); |
139 | void moveSourceRows(); |
140 | |
141 | void hierarchyFilterInvalidation(); |
142 | void simpleFilterInvalidation(); |
143 | |
144 | void chainedProxyModelRoleNames(); |
145 | |
146 | void noMapAfterSourceDelete(); |
147 | void forwardDropApi(); |
148 | void canDropMimeData(); |
149 | void filterHint(); |
150 | |
151 | void sourceLayoutChangeLeavesValidPersistentIndexes(); |
152 | void rowMoveLeavesValidPersistentIndexes(); |
153 | |
154 | void emitLayoutChangedOnlyIfSortingChanged_data(); |
155 | void emitLayoutChangedOnlyIfSortingChanged(); |
156 | |
157 | void checkSetNewModel(); |
158 | void filterAndInsertRow_data(); |
159 | void filterAndInsertRow(); |
160 | void filterAndInsertColumn_data(); |
161 | void filterAndInsertColumn(); |
162 | |
163 | void removeIntervals_data(); |
164 | void removeIntervals(); |
165 | |
166 | protected: |
167 | void buildHierarchy(const QStringList &data, QAbstractItemModel *model); |
168 | void checkHierarchy(const QStringList &data, const QAbstractItemModel *model); |
169 | void setupFilter(QSortFilterProxyModel *model, const QString& pattern); |
170 | |
171 | protected: |
172 | FilterType m_filterType; |
173 | |
174 | private: |
175 | QStandardItemModel *m_model = nullptr; |
176 | QSortFilterProxyModel *m_proxy = nullptr; |
177 | }; |
178 | |
179 | Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint) |
180 | |
181 | Q_DECLARE_LOGGING_CATEGORY(lcItemModels) |
182 | |
183 | #endif // TST_QSORTFILTERPROXYMODEL_H |
184 | |