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

source code of qtgraphs/src/graphs3d/data/qitemmodelsurfacedataproxy.h