1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QITEMMODELSURFACEDATAPROXY_H |
5 | #define QITEMMODELSURFACEDATAPROXY_H |
6 | |
7 | #include <QtCore/qabstractitemmodel.h> |
8 | #include <QtCore/qregularexpression.h> |
9 | #include <QtCore/qstringlist.h> |
10 | #include <QtGraphs/qsurfacedataproxy.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QItemModelSurfaceDataProxyPrivate; |
15 | |
16 | class Q_GRAPHS_EXPORT QItemModelSurfaceDataProxy : public QSurfaceDataProxy |
17 | { |
18 | Q_OBJECT |
19 | Q_DECLARE_PRIVATE(QItemModelSurfaceDataProxy) |
20 | Q_CLASSINFO("RegisterEnumClassesUnscoped" , "false" ) |
21 | Q_PROPERTY(QAbstractItemModel *itemModel READ itemModel WRITE setItemModel NOTIFY |
22 | itemModelChanged FINAL) |
23 | Q_PROPERTY(QString rowRole READ rowRole WRITE setRowRole NOTIFY rowRoleChanged FINAL) |
24 | Q_PROPERTY(QString columnRole READ columnRole WRITE setColumnRole NOTIFY columnRoleChanged FINAL) |
25 | Q_PROPERTY(QString xPosRole READ xPosRole WRITE setXPosRole NOTIFY xPosRoleChanged FINAL) |
26 | Q_PROPERTY(QString yPosRole READ yPosRole WRITE setYPosRole NOTIFY yPosRoleChanged FINAL) |
27 | Q_PROPERTY(QString zPosRole READ zPosRole WRITE setZPosRole NOTIFY zPosRoleChanged FINAL) |
28 | Q_PROPERTY(QStringList rowCategories READ rowCategories WRITE setRowCategories NOTIFY |
29 | rowCategoriesChanged FINAL) |
30 | Q_PROPERTY(QStringList columnCategories READ columnCategories WRITE setColumnCategories NOTIFY |
31 | columnCategoriesChanged FINAL) |
32 | Q_PROPERTY(bool useModelCategories READ useModelCategories WRITE setUseModelCategories NOTIFY |
33 | useModelCategoriesChanged FINAL) |
34 | Q_PROPERTY(bool autoRowCategories READ autoRowCategories WRITE setAutoRowCategories NOTIFY |
35 | autoRowCategoriesChanged FINAL) |
36 | Q_PROPERTY(bool autoColumnCategories READ autoColumnCategories WRITE setAutoColumnCategories |
37 | NOTIFY autoColumnCategoriesChanged FINAL) |
38 | Q_PROPERTY(QRegularExpression rowRolePattern READ rowRolePattern WRITE setRowRolePattern NOTIFY |
39 | rowRolePatternChanged FINAL) |
40 | Q_PROPERTY(QRegularExpression columnRolePattern READ columnRolePattern WRITE |
41 | setColumnRolePattern NOTIFY columnRolePatternChanged FINAL) |
42 | Q_PROPERTY(QRegularExpression xPosRolePattern READ xPosRolePattern WRITE setXPosRolePattern |
43 | NOTIFY xPosRolePatternChanged FINAL) |
44 | Q_PROPERTY(QRegularExpression yPosRolePattern READ yPosRolePattern WRITE setYPosRolePattern |
45 | NOTIFY yPosRolePatternChanged FINAL) |
46 | Q_PROPERTY(QRegularExpression zPosRolePattern READ zPosRolePattern WRITE setZPosRolePattern |
47 | NOTIFY zPosRolePatternChanged FINAL) |
48 | Q_PROPERTY(QString rowRoleReplace READ rowRoleReplace WRITE setRowRoleReplace NOTIFY |
49 | rowRoleReplaceChanged FINAL) |
50 | Q_PROPERTY(QString columnRoleReplace READ columnRoleReplace WRITE setColumnRoleReplace NOTIFY |
51 | columnRoleReplaceChanged FINAL) |
52 | Q_PROPERTY(QString xPosRoleReplace READ xPosRoleReplace WRITE setXPosRoleReplace NOTIFY |
53 | xPosRoleReplaceChanged FINAL) |
54 | Q_PROPERTY(QString yPosRoleReplace READ yPosRoleReplace WRITE setYPosRoleReplace NOTIFY |
55 | yPosRoleReplaceChanged FINAL) |
56 | Q_PROPERTY(QString zPosRoleReplace READ zPosRoleReplace WRITE setZPosRoleReplace NOTIFY |
57 | zPosRoleReplaceChanged FINAL) |
58 | Q_PROPERTY( |
59 | QItemModelSurfaceDataProxy::MultiMatchBehavior multiMatchBehavior READ multiMatchBehavior |
60 | WRITE setMultiMatchBehavior NOTIFY multiMatchBehaviorChanged FINAL) |
61 | |
62 | public: |
63 | enum class MultiMatchBehavior { |
64 | First, |
65 | Last, |
66 | Average, |
67 | CumulativeY, |
68 | }; |
69 | Q_ENUM(MultiMatchBehavior) |
70 | |
71 | explicit QItemModelSurfaceDataProxy(QObject *parent = nullptr); |
72 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, QObject *parent = nullptr); |
73 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, |
74 | const QString &yPosRole, |
75 | QObject *parent = nullptr); |
76 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, |
77 | const QString &rowRole, |
78 | const QString &columnRole, |
79 | const QString &yPosRole, |
80 | QObject *parent = nullptr); |
81 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, |
82 | const QString &rowRole, |
83 | const QString &columnRole, |
84 | const QString &xPosRole, |
85 | const QString &yPosRole, |
86 | const QString &zPosRole, |
87 | QObject *parent = nullptr); |
88 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, |
89 | const QString &rowRole, |
90 | const QString &columnRole, |
91 | const QString &yPosRole, |
92 | const QStringList &rowCategories, |
93 | const QStringList &columnCategories, |
94 | QObject *parent = nullptr); |
95 | explicit QItemModelSurfaceDataProxy(QAbstractItemModel *itemModel, |
96 | const QString &rowRole, |
97 | const QString &columnRole, |
98 | const QString &xPosRole, |
99 | const QString &yPosRole, |
100 | const QString &zPosRole, |
101 | const QStringList &rowCategories, |
102 | const QStringList &columnCategories, |
103 | QObject *parent = nullptr); |
104 | ~QItemModelSurfaceDataProxy() override; |
105 | |
106 | void setItemModel(QAbstractItemModel *itemModel); |
107 | QAbstractItemModel *itemModel() const; |
108 | |
109 | void setRowRole(const QString &role); |
110 | QString rowRole() const; |
111 | void setColumnRole(const QString &role); |
112 | QString columnRole() const; |
113 | void setXPosRole(const QString &role); |
114 | QString xPosRole() const; |
115 | void setYPosRole(const QString &role); |
116 | QString yPosRole() const; |
117 | void setZPosRole(const QString &role); |
118 | QString zPosRole() const; |
119 | |
120 | void setRowCategories(const QStringList &categories); |
121 | QStringList rowCategories() const; |
122 | void setColumnCategories(const QStringList &categories); |
123 | QStringList columnCategories() const; |
124 | |
125 | void setUseModelCategories(bool enable); |
126 | bool useModelCategories() const; |
127 | void setAutoRowCategories(bool enable); |
128 | bool autoRowCategories() const; |
129 | void setAutoColumnCategories(bool enable); |
130 | bool autoColumnCategories() const; |
131 | |
132 | void remap(const QString &rowRole, |
133 | const QString &columnRole, |
134 | const QString &xPosRole, |
135 | const QString &yPosRole, |
136 | const QString &zPosRole, |
137 | const QStringList &rowCategories, |
138 | const QStringList &columnCategories); |
139 | |
140 | Q_INVOKABLE qsizetype rowCategoryIndex(const QString &category); |
141 | Q_INVOKABLE qsizetype columnCategoryIndex(const QString &category); |
142 | |
143 | void setRowRolePattern(const QRegularExpression &pattern); |
144 | QRegularExpression rowRolePattern() const; |
145 | void setColumnRolePattern(const QRegularExpression &pattern); |
146 | QRegularExpression columnRolePattern() const; |
147 | void setXPosRolePattern(const QRegularExpression &pattern); |
148 | QRegularExpression xPosRolePattern() const; |
149 | void setYPosRolePattern(const QRegularExpression &pattern); |
150 | QRegularExpression yPosRolePattern() const; |
151 | void setZPosRolePattern(const QRegularExpression &pattern); |
152 | QRegularExpression zPosRolePattern() const; |
153 | |
154 | void setRowRoleReplace(const QString &replace); |
155 | QString rowRoleReplace() const; |
156 | void setColumnRoleReplace(const QString &replace); |
157 | QString columnRoleReplace() const; |
158 | void setXPosRoleReplace(const QString &replace); |
159 | QString xPosRoleReplace() const; |
160 | void setYPosRoleReplace(const QString &replace); |
161 | QString yPosRoleReplace() const; |
162 | void setZPosRoleReplace(const QString &replace); |
163 | QString zPosRoleReplace() const; |
164 | |
165 | void setMultiMatchBehavior(QItemModelSurfaceDataProxy::MultiMatchBehavior behavior); |
166 | QItemModelSurfaceDataProxy::MultiMatchBehavior multiMatchBehavior() const; |
167 | |
168 | Q_SIGNALS: |
169 | void itemModelChanged(const QAbstractItemModel *itemModel); |
170 | void rowRoleChanged(const QString &role); |
171 | void columnRoleChanged(const QString &role); |
172 | void xPosRoleChanged(const QString &role); |
173 | void yPosRoleChanged(const QString &role); |
174 | void zPosRoleChanged(const QString &role); |
175 | void rowCategoriesChanged(); |
176 | void columnCategoriesChanged(); |
177 | void useModelCategoriesChanged(bool enable); |
178 | void autoRowCategoriesChanged(bool enable); |
179 | void autoColumnCategoriesChanged(bool enable); |
180 | void rowRolePatternChanged(const QRegularExpression &pattern); |
181 | void columnRolePatternChanged(const QRegularExpression &pattern); |
182 | void xPosRolePatternChanged(const QRegularExpression &pattern); |
183 | void yPosRolePatternChanged(const QRegularExpression &pattern); |
184 | void zPosRolePatternChanged(const QRegularExpression &pattern); |
185 | void rowRoleReplaceChanged(const QString &replace); |
186 | void columnRoleReplaceChanged(const QString &replace); |
187 | void xPosRoleReplaceChanged(const QString &replace); |
188 | void yPosRoleReplaceChanged(const QString &replace); |
189 | void zPosRoleReplaceChanged(const QString &replace); |
190 | void multiMatchBehaviorChanged(QItemModelSurfaceDataProxy::MultiMatchBehavior behavior); |
191 | |
192 | private: |
193 | Q_DISABLE_COPY(QItemModelSurfaceDataProxy) |
194 | |
195 | friend class SurfaceItemModelHandler; |
196 | }; |
197 | |
198 | QT_END_NAMESPACE |
199 | |
200 | #endif |
201 | |